multiple select option

Ask about general coding issues or problems here.

Moderators: egami, macek, gesf

Post Reply
acellec
php-forum Active User
php-forum Active User
Posts: 26
Joined: Thu May 17, 2012 5:44 pm

Sat Jun 23, 2012 10:37 am

how can i display 3 option chosen in my multiple select option box with below code.

Code: Select all

$query6="SELECT * FROM  $TableNamee";
$result6 = mysql_query ($query6);
echo "<select name=\"Fund\" multiple=\"multiple\" id=\"Fund$incTextBox\">";
// printing the list box select command
while($nt=mysql_fetch_array($result6)){//Array or records stored in $nt
echo '<option '.(trim($nt['fundname']) == trim($srcfund) ? ' selected ' : '').' value="'.trim($nt['fundname']).'" >'.$nt['fundcode'].'-'.$nt['fundname'].'</option>'; 
}
echo "</select>";// Closing of list box */
johnj
php-forum GURU
php-forum GURU
Posts: 1803
Joined: Thu Mar 10, 2011 5:07 pm

Sat Jun 23, 2012 10:53 pm

Create three more <option tags with selected=selected
acellec
php-forum Active User
php-forum Active User
Posts: 26
Joined: Thu May 17, 2012 5:44 pm

Sun Jun 24, 2012 8:02 am

i dont get it..how to do that?
acellec
php-forum Active User
php-forum Active User
Posts: 26
Joined: Thu May 17, 2012 5:44 pm

Sun Jun 24, 2012 5:00 pm

Please anyone help me?
johnj
php-forum GURU
php-forum GURU
Posts: 1803
Joined: Thu Mar 10, 2011 5:07 pm

Mon Jun 25, 2012 2:34 am

example:

<select name="something" multiple="multiple">
<option value="1" selected="selected">Apple</option>
<option value="2" selected="selected">Grape</option>
<option value="3" selected="selected">Strawberry</option>
<option value="4">Papaya</option>
</select>

In this case, the first three will be selected.
Post Reply