To use the double-click mouse action you need to use the ondblclick() event handler.
In this example, we will use the double click action to display selected text in a SELECT in another field.
First, you will need to add the following Javascript to the HEAD section of your HTML document. Ensure the code is between the script tags.
<SCRIPT LANGUAGE="JAVASCRIPT">
<!--
function move_selected()
{
var w = document.form.selected_list.selectedIndex;
document.form.new_text.value = document.form.selected_list.options[w].text;
}
//-->
</SCRIPT>
Now, you must create a selection list and a text field.
NOTE: ondblclick() will only work if the size of the selection list is greater than 1.
<FORM NAME="form">
<SELECT NAME="selected_list" ondblclick="move_selected()" SIZE="2">
<OPTION VALUE="1">Item One
<OPTION VALUE="2">Item Two
<OPTION VALUE="3">Item Three
</SELECT>
<BR />
<INPUT TYPE="TEXT" VALUE="" NAME="new_text" SIZE="15">
</FORM>
Thats it. Now all you have to do, is double click one of the list item, and it'll magically appear in the text box.
Posted by OLLIE at 10:16am
No comments yet. Be the first to add one!