Jump to content

Variables in a Multiple select drop down


scrbowler

Recommended Posts

You need to create an array for these values, so here is an example.

 

HTML

<form>
   <select name="choices[]" multiple="multiple">
         <option>...</option>
         <option>...</option>
         <option>...</option>
         <option>...</option>
         <option>...</option>
         <option>...</option>
   </select>
</form>

 

Now when they submit the form, all the selected values will be in the array $_POST['choices']

Link to comment
Share on other sites

I've been giving this the ole college try and nothing seems to work for what I want when it comes to assigning a variable to the results of the form.

 

As you see in the code below I have a couple of efforts to make the variable available to the array list but I can't get it to post using the examples below.  Any help in assigning the variables to the choices will be greatly appreciated.  I'm trying to use the variables $driver1, $driver2 .... and so forth for the 5 selections from the form.

 

thanks

Steve

 

<form name="entry" method="post" action="<? echo $PHP_POST; ?>">
   <select name="choices[]" multiple="multiple">
         <option><input type="radio" name="#48 Jimmie Johnson" value="48" />#48 Jimmie Johnson</option><br>
         <option><input type="radio" name="#24 Jeff Gordon" value="24" />#24 Jeff Gordon</option><br>
         <option><input type="radio" name="#07 Clint Bowyer" value="107" />#07 Clint Bowyer</option><br>
         <option><input type="radio" name="#17 Matt Kenseth" value="17" />#17 Matt Kenseth</option><br>
         <option><input type="radio" name="#5 Casey Mears" value="5" />#5 Casey Mears</option><br>
         <option><input type="radio" name="#20 Tony Stewart" value="20" />20 Tony Stewart</option><br>
         <option><input type="radio" name="#77 Sam Hornisch Jr." value="77" />#77 Sam Hornisch Jr.</option><br>
         <option><input type="radio" name="#31 Jeff Burton" value="31" />#31 Jeff Burton</option><br>
         <option><input type="radio" name="#99 Carl Edwards" value="99" />#99 Carl Edwards</option>
   </select>
<input type="submit" name="submit" value="Send" />

</form>
<?

$ID=array($_POST, $choices, "choices[2]", "choices[3]", "choices[4]"); //trying 3 diff attempt for values but no luck
for($count = 0; $count < sizeof($ID); $count++) { 
$IDarray[]=$ID[$count]; 
} 
foreach($IDarray as $key => $val) { 
print("$key -- $val<br />"); 
} 


?> 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.