<DIV>Hi Steve,</DIV>
<DIV> </DIV>
<DIV>Are you getting the entries out of a database or are you setting them straight off with static values?</DIV>
<DIV> </DIV>
<DIV>You haven't got a closing tag on your option tag in your html i.e. "</option>" so this could be the problem for starters.</DIV>
<DIV> </DIV>
<DIV>If you send the section of code you are talking about it's probably easier to work out.</DIV>
<DIV> </DIV>
<DIV>Sarah</DIV>
<DIV> </DIV>
<DIV><BR>----- Original Message -----<BR>From: Steve Edwards <killshot91@comcast.net><BR>Date: Wednesday, November 28, 2007 3:04 pm<BR>Subject: Re: [support] How to add "selected" attribute to select list <option>tag<BR>To: support@drupal.org<BR><BR>> Hmmm, getting closer, but I can't seem to get it to work. <BR>> No matter what I try, I can't get it to select anything.<BR>> <BR>> Here is what my select list looks like (in HTML)<BR>> <BR>> <option value="1">Name 1<BR>> <option value="2">Name 2<BR>> <option value="3">Name 3<BR>> <option value="4">Name 4<BR>> <option value="5">Name 5<BR>> <BR>> The value is the user's uid. number That being the case, what <BR>> would i use for #default_value? I've tried things like<BR>> <BR>> '#default_value' => array(1 => 'Name 1')<BR>> '#default_value' => 1<BR>> '#default_value' => 'Name 1'<BR>> <BR>> but I can't get any of them to work. Any ideas?<BR>> <BR>> Thanks.<BR>> <BR>> Steve<BR>> <BR>> <BR>> Greg Holsclaw wrote:<BR>> > Make the #default_value an array of the keys of the options <BR>> you want<BR>> > selected.<BR>> > <BR>> > $form['item'] = array(<BR>> > '#type' => 'select',<BR>> > ...<BR>> > '#options' => array of all options,<BR>> > '#default_value' => array of keys from above options.<BR>> > ...<BR>> > );<BR>> > <BR>> > Check<BR>> > <BR>> http://api.drupal.org/api/file/developer/topics/forms_api_reference.html> /5#default_value for more info.<BR>> > <BR>> > Greg<BR>> > <BR>> > <BR>> > -----Original Message-----<BR>> > From: support-bounces@drupal.org [mailto:support-<BR>> bounces@drupal.org] On<BR>> > Behalf Of Steve Edwards<BR>> > Sent: Tuesday, November 27, 2007 8:25 PM<BR>> > To: support@drupal.org<BR>> > Subject: [support] How to add "selected" attribute to select list<BR>> > <option>tag<BR>> > <BR>> > Well, I'm back again, and this time I have a question about <BR>> attributes> for select options in a form. I have a form <BR>> that has a <BR>> > select element (multi-select) that lists users. The form <BR>> is for some<BR>> > admin settings for a module. When the form is displayed, <BR>> I <BR>> > need to be able to highlight specific options in the list <BR>> based on data<BR>> > returned from a query. I've been looking all day, and <BR>> > haven't been able to figure it out. There is the <BR>> #attribute key, but it<BR>> > is for the field as whole (at least as far as I can <BR>> > determine), and doesn't work for each individual <option> tag.<BR>> > <BR>> > If anybody could point me in the right direction, I would <BR>> appreciate it.<BR>> > <BR>> > Thanks.<BR>> > <BR>> > Steve<BR>> -- <BR>> [ Drupal support list | http://lists.drupal.org/ ]<BR>> </DIV><BR><BR>Research Computing Services
<br>Sarah.Vardy@student.griffith.edu.au
<br>0402241794</BR></BR>