eva21 Posted May 14, 2009 Share Posted May 14, 2009 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 https://forums.phpfreaks.com/topic/158047-php-and-selecting-more-than-one-element-in-a-list-box-using-html/ Share on other sites More sharing options...
ohdang888 Posted May 14, 2009 Share Posted May 14, 2009 only 1 option can be selected from each <select> tag Link to comment https://forums.phpfreaks.com/topic/158047-php-and-selecting-more-than-one-element-in-a-list-box-using-html/#findComment-833708 Share on other sites More sharing options...
eva21 Posted May 14, 2009 Author Share Posted May 14, 2009 Why can i select more than one than? I must be able to select more than one using php Link to comment https://forums.phpfreaks.com/topic/158047-php-and-selecting-more-than-one-element-in-a-list-box-using-html/#findComment-833713 Share on other sites More sharing options...
ohdang888 Posted May 14, 2009 Share Posted May 14, 2009 Nope, its not possible. If you have ONE select tag, that input can only have ONLY value defined in it.... If you say 2 are selected, then it will just display the top one, depending on your browser Link to comment https://forums.phpfreaks.com/topic/158047-php-and-selecting-more-than-one-element-in-a-list-box-using-html/#findComment-833735 Share on other sites More sharing options...
Ken2k7 Posted May 14, 2009 Share Posted May 14, 2009 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 https://forums.phpfreaks.com/topic/158047-php-and-selecting-more-than-one-element-in-a-list-box-using-html/#findComment-834395 Share on other sites More sharing options...
ohdang888 Posted May 15, 2009 Share Posted May 15, 2009 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 https://forums.phpfreaks.com/topic/158047-php-and-selecting-more-than-one-element-in-a-list-box-using-html/#findComment-834447 Share on other sites More sharing options...
Ken2k7 Posted May 15, 2009 Share Posted May 15, 2009 Read it and weep. http://www.w3schools.com/TAGS/att_select_multiple.asp Link to comment https://forums.phpfreaks.com/topic/158047-php-and-selecting-more-than-one-element-in-a-list-box-using-html/#findComment-834453 Share on other sites More sharing options...
timmah1 Posted May 15, 2009 Share Posted May 15, 2009 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 https://forums.phpfreaks.com/topic/158047-php-and-selecting-more-than-one-element-in-a-list-box-using-html/#findComment-834520 Share on other sites More sharing options...
Ken2k7 Posted May 15, 2009 Share Posted May 15, 2009 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 https://forums.phpfreaks.com/topic/158047-php-and-selecting-more-than-one-element-in-a-list-box-using-html/#findComment-834544 Share on other sites More sharing options...
ohdang888 Posted May 15, 2009 Share Posted May 15, 2009 It could be that ohdang888 is unaware of select's multiple attribute. That's exactly it. Never used them before. There's better ways to say that other than "Don't listen to ohdang888". Just pointing that out. Link to comment https://forums.phpfreaks.com/topic/158047-php-and-selecting-more-than-one-element-in-a-list-box-using-html/#findComment-834804 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.