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?

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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>");
?>

Link to comment
Share on other sites

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.

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.