Printable Version of Topic

Click here to view this topic in its original format

HTMLHelp Forums _ Client-side Scripting _ Which events are called?

Posted by: msucimaster Mar 21 2021, 04:13 PM

I want to show a picture when an entry in a select box an entry is selected. It should be shown immediately as it is meant as a help for people to choose the right option. So I need to know which events are generated that I can use.

The selected box has multiple rows (size=4).

Can someone help me with this information?

Posted by: pandy Mar 21 2021, 04:31 PM

onchange for the SELECT. The value for SELECT is the value of the chosen option.

CODE
function getOption(x)
{
   alert(x);
}


HTML
<select onchange="getOption(this.value);">
<option selected>Choose a Pet</option>
<option value="dog">Dog</option>
<option value="cat">Cat</option>
<option value="parrot">Parrot</option>
</select>


Note that the returned value is that of the value attribute, not what's visible on the page. So if the first option is chosen 'dog' not 'Dog' will be returned.

Posted by: msucimaster Mar 22 2021, 01:51 PM

Thank you.

Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)