Jump to content

Multiple Selectbox "SELECT" Attribute?


jamesjmann

Recommended Posts

I know this is probably going to sound like a stupid question, but I have a multiple select box with this code:

 

<select MULTIPLE>

</select>

 

And a foreach statement that dynamically generates <option>'s.

 

I want one option to be automatically selected when the user clicks the page, depending on a certain $_GET variable in the query string.

 

I tried:

 

<option SELECTED>

 

Like you would a normal <select> and this didn't work. Anyone know if this is even possible?

 

Note: I tried googling it, but google turned up nothing. Someone help. I'm a newb at multiple selects lol.

Link to comment
Share on other sites

Following works for me -

<form action="formaction.php">
<select multiple="multiple" name="cars[]">
  <option value="volvo">Volvo</option>
  <option value="saab">Saab</option>
  <option value="opel" selected="selected">Opel</option>
  <option value="audi">Audi</option>
</select>
<input type="submit" />
</form>

 

Are you sure you output the correct syntax in your actual form?

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.