Hi what I am basically trying to do with this form is make a dropdown list output the selection into a textbox. I know it needs to be onchange but I can't seem to do this correctly with the options. Please help if you can. <select id="WHATOUTPUTS" name="state" onclick="document.getElementById('textbox').value = this.id"> <option id="WHATDOESNOTOUTPUT" value="CA">California</option> <option value="WHATDOESNOTOUTPUT">Nevada</option> </select> <input type="text" id="textbox" value="" />
Yes but the problem with this is it only changes on state.. it wont work for changing to other values (of lets say a list of 10 variables) <select id="WHATOUTPUTS" name="state" onchange="document.getElementById('textbox').value = this.id"> <option id="WHATDOESNOTOUTPUT" value="CA">California</option> <option id="WHATDOESNOTOUTPUT2" value="CA">Nevada</option> <option id="WHATDOESNOTOUTPUT3" value="CA">UTAH</option> </select> <input type="text" id="textbox" value="" />
<select id="WHATOUTPUTS" name="state" onchange="document.getElementById('textbox').value = [LEFT][COLOR=#000000][FONT=Courier New]this.options[this.selectedIndex].value"> Code (markup): That will grab the value for your selected option - i think to grab the "id" of it can be like this ... = [/FONT][/COLOR][COLOR=#000000][FONT=Courier New]this.options[this.selectedIndex].id"> Code (markup): "this.id" is grabbing the actual element you are in (the selectbox) which is what "this" represents. You were looking for it's "options" and than select the appropriate one, as shown above.[/FONT][/COLOR][/LEFT]