how to do form #options and 'selected'?
ubuntu - April 8, 2008 - 18:58
I want to have something like
blue team
green team
purple team
The following code won't cut it. I don't know how to add 'SELECTED' in an option?
<?php
$form['teams'] = array(
'#type' => 'select',
'#title' => t('teams'),
'#multiple' => true,
'#options' => array('b'=>'blue team', 'g'=>'green team', 'p'=>'purple team'),
);
?>
It didn't take my html. Let
It didn't take my html. Let me put in php wrapper
I wan to add 'selected' for multiple options.
<?php
/*
<SELECT NAME="teams" MULTIPLE SIZE=6>
<OPTION VALUE="b" >blue team
<OPTION VALUE="g" SELECTED >green team
<OPTION VALUE="p" SELECTED >purple team
</SELECT>
*/
I don't see a way to add in 'selected' to the options.
$form['teams'] = array(
'#type' => 'select',
'#title' => t('teams'),
'#multiple' => true,
'#options' => array('b'=>'blue team', 'g'=>'green team', 'p'=>'purple team'),
);
?>
any help is appreciated!
Use #default_value
Use #default_value
thanks for your response.
thanks for your response. can you elaborate?
How to add default value to multiple options? I need more than one values be selected. Can you add a little snippet? Thanks again.
I got it to work. Thanks for
I got it to work. Thanks for the help.
I added an array in default_value.
pls share
Hi,
Can you share your finding and how i go about if I wanted to put 'selected' on currently selected on this jump menu.
http://drupal.org/node/91924