Thomas Meinike: Pulldownmenue (Dynamisches 'selected')

Beitrag lesen

Hallo,

Klicke ich nun in Datei inhalt.php einen Link an, so soll das selected-Attribut einem anderen <option>-Tag zugeordnet werden (z.B. dem option Tag mit 'value=spiele' -> <option value="spiele" selected>). Ich denke ich muss hier was mit dem onClick Event-Handler machen.

Probiere es mal so:

<form action="" name="x">
  <select name="y">
    <option value="1">Eintrag 1</option>
    <option value="2">Eintrag 2</option>
    <option value="3">Eintrag 3</option>
    <option value="4">Eintrag 4</option>
    <option value="5">Eintrag 5</option>
  </select>
</form>
<a href="" onclick="document.x.y.options[0].selected=true;return false">1</a>
<a href="" onclick="document.x.y.options[1].selected=true;return false">2</a>
<a href="" onclick="document.x.y.options[2].selected=true;return false">3</a>
<a href="" onclick="document.x.y.options[3].selected=true;return false">4</a>
<a href="" onclick="document.x.y.options[4].selected=true;return false">5</a>

MfG, Thomas