Jump to content

php and selecting more than one element in a list box using html


eva21

Recommended Posts

In my php:

echo("<Select size=3 MULTIPLE onchange='getBlendMedia(" . $rows['id'] . ")' name='" . $rows['id'] . "_teach[]' id='" . $rows['id'] . "_teach'>");

echo("<option value='t1' " . selectMatch("t1",$teach_list[0]) . " >Simple </option>");

 

selectMatch is a php function that returns "SELECTED"....but i have like 3 options but only one of them is selected. Why arent the other ones being selected?

eva21, don't pay attention to ohdang88. From the code you posted, I can't determine if you're writing it correctly. If you view source it, do you see the options you want selected have the selected attribute in them? Or post some more code. It would help if you post the selectMatch() function as well.

 

Thanks!

eva21, don't pay attention to ohdang88. From the code you posted, I can't determine if you're writing it correctly. If you view source it, do you see the options you want selected have the selected attribute in them? Or post some more code. It would help if you post the selectMatch() function as well.

 

Thanks!

 

maybe i'm misunderstanding him...but when you have a <select> tag, you can't select more than one value correct?

ohdang888 AND Ken2k7, your both right.

 

With the standard <select> tag like eva21 is doing, you cannot select more than one, so ohdang888 is right.

 

With a <select multiple="multiple"> tag, you can select more than one, so Ken2k7 is right.

 

So to answer ea21's original question

 

<?php
echo("<select size='3' multiple='multiple' onchange='getBlendMedia(" . $rows['id'] . ")' name='" . $rows['id'] . "_teach[]' id='" . $rows['id'] . "_teach'>");
echo("<option value='t1' " . selectMatch("t1",$teach_list[0]) . " >Simple </option>");
?>

I never said ohdang888 is wrong. But it would have helped if ohdang888 looked at eva21's code to realize the select had the multiple attribute, even if her HTML is not valid xHTML. It could be that ohdang888 is unaware of select's multiple attribute.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.