[FX.php List] How do I pass multi select items to FM

Larry Schultz larry at macedge.net
Wed May 2 23:01:06 MDT 2007


Gjermund,
Thank you for the reply. I believe it does have something to do with  
imploding the array, but I can't get it to work. I am using two pages  
to do this. The first is the add.php page, and the second is the  
add_results.php page.

Adding the code you suggested (code) I still create a new FM record  
on Submit, however no fields get posted!

Got Clues?

TIA,
Larry

in the add.php page I've done this: (I pulled a lot of fields to make  
it shorter for this post) Also the red lines are where I added your  
code.
<?php require_once('../Connections/PeritusFX.php'); ?>


<?php // FMStudioFX v1.0 - do not remove comment, needed for  
DreamWeaver support ?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"  
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>New Record - PeritusMonSite</title>
<style type="text/css">
<!--
.style1 {font-family: Verdana, Arial, Helvetica, sans-serif}
.style3 {font-size: 10px}
.style4 {font-family: Verdana, Arial, Helvetica, sans-serif; font- 
size: 12px; }
.style5 {font-size: 12px}
.style8 {font-size: 18px}
.style9 {font-weight: bold; font-family: Verdana, Arial, Helvetica,  
sans-serif;}
-->
</style>
</head>
<body>
<div align="center" class="style8"><span class="style9">Welcome to  
the Peritus Translations Translator Application Page
   <!--<a href="index.php">Home</a>
-->
   </span></div>
<hr align="center" />
<form name="addnew" method="post" action="add_result.php">
   <table align="CENTER" cellpadding="2" cellspacing="0">
     <tr>
       <th><div align="right" class="style4">First Name </div></th>
       <td><input type="text" name="NameFirst" value="">      </td>
     </tr>

     <tr>
       <th><div align="right" class="style4">Last Name </div></th>
       <td><input type="text" name="NameLast" value="">      </td>
     <tr>
       <th><div align="right" class="style4">Company Name </div></th>
       <td><input name="Company_Name" type="text" value=""></td>
     </tr>
     <tr>
       <th><div align="right" class="style4">Language You Translate  
 From </div></th>
		   <td>
			<select multiple="true" id="Language_you_translate_fromID"  
name="Language_you_translate_from[]">
				<?php
					foreach(fmsValueListItems 
($PeritusFX,'NewTranslatorOnlineProfile_Web','LanguageSingle') as  
$list_item) {
					  if($list_item == "") {
						echo "<option value=\"{$list_item}\" selected=\"selected\"> 
{$list_item}</option>\n";
					  } else {
						echo "<option value=\"{$list_item}\">{$list_item}</option>\n";
					  }
					}
				?>
			</select>		</td>
     </tr>
     <tr>
       <th><div align="right" class="style4">Language You Translate  
Into </div></th>
             <td>
			<select name="Language_you_translate_into">
				<?php
					foreach(fmsValueListItems 
($PeritusFX,'NewTranslatorOnlineProfile_Web','LanguageSingle') as  
$list_item) {
					  if($list_item == "") {
						echo "<option value=\"{$list_item}\" selected=\"selected\"> 
{$list_item}</option>\n";
					  } else {
						echo "<option value=\"{$list_item}\">{$list_item}</option>\n";
					  }
					}
				?>
			</select>		</td>
     </tr>
     <tr>
       <th><div align="right" class="style4">Length of U S Residency</ 
div></th>
       <td><input type="text" name="Length_of_US_Residency"  
value="">      </td>
     </tr>
     <tr>
       <th><div align="right" class="style4">Other Residencies</div></ 
th>
       <td><input type="text" name="Other_Residencies" value="">       
</td>
     </tr>

     <tr>
       <th><div align="right"><span class="style1"><span  
class="style1"><span class="style1"><span class="style3"><span  
class="style3"><span class="style3"><span class="style5"><span  
class="style5"></span></span></span></span></span></span></span></ 
span></div></th>
       <td><input type="submit" name="addnew_submit" value="Submit To  
Peritus">      </td>
     </tr>
   </table>
</form>
</body>
</html>

in the add_results.php page I've done this: (I pulled a lot of fields  
to make it shorter for this post)
<?php require_once('../Connections/PeritusFX.php'); ?>

<?php
$add_result_add = clone($PeritusFX);
$add_result_add->layout = 'NewTranslatorOnlineProfile_Web';
$add_result_fields = array('NameFirst'=>$_POST 
['NameFirst'],'NameLast'=>$_POST['NameLast'],
'Company_Name'=>$_POST['Company_Name'],
'Language_you_translate_from[]'=>$_POST['Language_you_translate_from'],
'Language_you_translate_into'=>$_POST['Language_you_translate_into'],
);
foreach($add_result_fields as $key=>$value) {
   $add_result_add->AddDBParam('Language_you_translate_from',
implode( "\n", $Language_you_translate_from ));
}

$add_result_result = $add_result_add->FMNew();

if(is_a($add_result_result,"FX_Error") || $add_result_result 
['errorCode'] != "0") fmsTrapError($add_result_result,"error.php");

$add_result_row = current($add_result_result['data']);
$add_result_row_key = key($add_result_result['data']);
// FMStudioFX v1.0 - do not remove comment, needed for DreamWeaver  
support ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"  
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Record Added - fmsTitle</title>
</head>

<body>
<h1>The record has been added </h1>
<a href="index.php">Home</a>
<hr />
Please go back to the <a href="index.php">home page</a>
</body>
</html>

On May 2, 2007, at 12:33 AM, Gjermund Gusland Thorsen wrote:

> change name of variable to: Language_you_translate_from[]
>
> add_result_add->AddDBParam( 'whateverFieldYouWouldLikeToFill',
> implode( "\n", $Language_you_translate_from ) );
>
> ggt667
>
> On 5/2/07, Larry Schultz <larry at macedge.net> wrote:
>> I'm trying to use a multi select value list.
>> I do get the multi select list, and I AM able to select multiple
>> items. The problem is I don't know how to pass them on to FM through
>> the results page.
>> Any help is appreciated.
>>
>> Add:
>> <select multiple="true" name="Language_you_translate_from">
>>         <?php
>>                 foreach(fmsValueListItems
>> ($PeritusFX,'NewTranslatorOnlineProfile_Web','LanguageSingle') as
>> $list_item) {
>>                          if($list_item == "") {
>>                                 echo "<option value=\"{$list_item} 
>> \" selected=\"selected\">
>> {$list_item}</option>\n";
>>                          } else {
>>                                 echo "<option value=\"{$list_item} 
>> \">{$list_item}</option>\n";
>>                           }
>>                         }
>>         ?>
>> </select>
>>
>>
>> Post:
>> <?php
>> $add_result_add = clone($PeritusFX);
>> $add_result_add->layout = 'NewTranslatorOnlineProfile_Web';
>> $add_result_fields = array('Language_you_translate_from'=>$_POST
>> ['Language_you_translate_from'],
>> );
>> foreach($add_result_fields as $key=>$value) {
>>      $add_result_add->AddDBParam($key,$value);
>> }
>>
>> $add_result_result = $add_result_add->FMNew();
>>
>>
>>
>> _______________________________________________
>> FX.php_List mailing list
>> FX.php_List at mail.iviking.org
>> http://www.iviking.org/mailman/listinfo/fx.php_list
>>
> _______________________________________________
> FX.php_List mailing list
> FX.php_List at mail.iviking.org
> http://www.iviking.org/mailman/listinfo/fx.php_list

Larry Schultz
             Mac Edge Corporation
Specializing in Filemaker Pro Relational Database Solutions
                             for Mac/Windows/NT

FBA Member


larry at macedge.net
larryschultz1 at mac.com
408-996-0831
510-502-4365

           -------------Take A Deep Breath-------------

  "I quickly discovered that Apple, Inc., isn’t just a company.  It’s  
the world’s only publicly traded religion. "
Brett Arends, Boston Herald Finance Columnist  December 2005


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.iviking.org/pipermail/fx.php_list/attachments/20070502/5dafeb2c/attachment-0001.html


More information about the FX.php_List mailing list