XHTML, can all of you web developers help me?

October 23, 2009 - 4:36 am

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

2 Responses to “XHTML, can all of you web developers help me?”

  1. SadButTrue Says:

    Try the following:
    References :
    <select onchange="alert( this.options[ this.selectedIndex ].text );">
    <option>A</option>
    <option>B</option>
    <option>C</option>
    </select>

  2. PayneLessDesigns.com Says:

    <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 :

Leave a Reply