View Full Version : writing a function to select an option in a select dropdown list based on the label

10-16-2005, 12:19 AM
i have a select dropdown list, with 4 options like this..

<select name="riskstrategytype">
<option value="">
<option value="1">Business
<option value="2">Final
<option value="3">Technical

then say inside a cell in a table i have something like this:

<td id="selectedType">

is there a way where when i click a link/button have the select dropdown menu select whatever was in the cell?

here's the example:


i want it so that when they click on "The Title" link, in the drop down menu above it'll select "Final" because it says Final in the 2nd row/2nd col


10-16-2005, 08:04 AM
This should do the trick:

function change() {
document.formname.riskstrategytype[2].selected = true;
<form name="formname">
<select name="riskstrategytype">
<option value="0" selected>
<option value="1">Business
<option value="2">Final
<option value="3">Technical
<input type="reset" value="reset">
<a href="javascript:change();">Final</a>

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum