views:

13

answers:

1

In functions php, this works like a charm:

<textarea name="menu1anchor" id="menu1anchor" cols="40" rows="1"><?php echo get_option('menu1anchor'); ?></textarea>

How can i make this drop down list work? I want to be able to input my values and select a desired one later on.

Right now, it does not matter which value I select, after i press "save changes" it does not send my value thru the form to wordpress options.

<select name="menu1" id="menu1">
     <option value="1">Microsoft</option>
     <option value="2">Google</option>
     <option value="3">Apple</option>
     </select>

Thank u!

+1  A: 
<select name="menu1" id="menu1">
     <option value="1"<?php selected(get_option('menu1'),1); ?>>Microsoft</option>
     <option value="2"<?php selected(get_option('menu1'),2); ?>>Google</option>
     <option value="3"<?php selected(get_option('menu1'),3); ?>>Apple</option>
     </select>

Try that instead.

John P Bloch
It works, this is the second really cool code you made for me;) Where should i send the beer?:) Will it work if i try this?<option value="testvalue"<?php selected(get_option('menu1'),'testvalue'); ?>>Microsoft</option>I just love coding wordpress, even if I'm a newb, you should see some interesting codes i did... I'm a webmaster, but would love to become a wordpress coder someday:)
webmasters
That will work. The way the `selected()` function (and `checked()` and `disabled()`) works is, if both arguments are equal, it echoes the code necessary to make the option selected (or checked, or disabled).
John P Bloch