XHTML, can all of you web developers help me?
I have a <select> tag that has several <option> tags under it. What I’m trying to do is, if an option is clicked, a brief description will be displayed.
I tried to do it with Javascript, however, all option’s descriptions are displayed, not only the one I clicked. Is there any other way to do it? Or perhaps is there a clear option that clears whatever has been typed? Thanks.
<form name="jump1" action="select">
<p>
<select name="MyList" OnChange="location.href=jump1.MyList.options[selectedIndex].value">
<option selected>Please Select…</option>
<option value="index.html">My Home Page</option>
<option value="http://www.crystalfibers.com/">Crystalfibers.com</option>
<option value="http://PayneLessDesigns.com/">PayneLessDesigns.com</option>
<option value="http://answers.yahoo.com/">Yahoo!Answers</option>
</select>
</p>
</form>
Added spaces so this would not be shorted by YA. Remove them for correct code:
OnChange="location. href=jump1. MyList. options[selectedIndex]. value
Ron
October 23rd, 2009 at 9:59 am
Try the following:
References :
<select onchange="alert( this.options[ this.selectedIndex ].text );">
<option>A</option>
<option>B</option>
<option>C</option>
</select>
October 23rd, 2009 at 10:29 am
<form name="jump1" action="select">
<p>
<select name="MyList" OnChange="location.href=jump1.MyList.options[selectedIndex].value">
<option selected>Please Select…</option>
<option value="index.html">My Home Page</option>
<option value="http://www.crystalfibers.com/">Crystalfibers.com</option>
<option value="http://PayneLessDesigns.com/">PayneLessDesigns.com</option>
<option value="http://answers.yahoo.com/">Yahoo!Answers</option>
</select>
</p>
</form>
Added spaces so this would not be shorted by YA. Remove them for correct code:
OnChange="location. href=jump1. MyList. options[selectedIndex]. value
Ron
References :