HTML forms selection list and double-clicks
Sponsored Links
The double-click mouse action is captured by ondblclick() event handler. We'll see how to use it in a selection list to display the selected text in another text field.
IMP: For ondblclick() to work, the size of the selection list must be more than 1.
Put the function below in the HTML head section between the SCRIPT tags
<SCRIPT LANGUAGE="JAVASCRIPT">
<!--
function put_it()
{
var w = document.myform.sel_list.selectedIndex;
document.myform.r_text.value =
document.myform.sel_list.options[w].text;
}
//-->
</SCRIPT>
Now, we create the selection list and the text field.
<FORM NAME="myform"> <SELECT NAME="sel_list" ondblclick="put_it()" SIZE="3"> <OPTION VALUE="value1">The First Item <OPTION VALUE="value2">The Second Item <OPTION VALUE="value3">The Third Item <OPTION VALUE="value4">The Fourth Item <OPTION VALUE="value5">The Fifth Item </SELECT> <BR> <INPUT TYPE="TEXT" VALUE="" NAME="r_text" SIZE="20"> </FORM>
Here is how it works. Double-click on any item in the selection list to display it in the text field.
IMP: This might not work in Netscape Navigator.
Page contents: Learn how to use the mouse double-click with the JavaScript ondblclick() function to get the text of an item from an HTML forms selection list and display it on a web page.
Comments, questions, feedback... whatever!
Recent Articles
Recent Blog Posts
Popular Articles
- Hotmail Sign In page
- Create a Hotmail account - Instructions
- Create Gmail address
- Download and install Outlook Express
- Get your free Gmail address
- Outlook Express new version
- Create my own email address
- Browers for Windows list
- Get email address
- Color combinations for web sites and pages
- Create Yahoo ID
More web tips & tricks
- Outlook Express Help - tips & tricks (53)
- Windows Live Mail help and tips (36)
- Windows Mail help (25)
- Hotmail help and tips (42)
- Yahoo help & support (45)
- AOL email help (26)
- Gmail help and tips (36)
- Internet tips & tricks (12)
- Web Design tips & tricks (33)
- HTML, Javascript tips tricks (68)
- Web Promotion tips & tricks (8)
- Graphics tips & tricks (20)
