General discussion

Locked

HTML - VB Script - Java

By vhansen86 ·
In a webpage form I want to put focus on a particular text box when a particular checkbox or radio button is selected.

This conversation is currently closed to new comments.

5 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

HTML - VB Script - Java

by DeVry Student In reply to HTML - VB Script - Java

You need to add onclick to the list of attributes for either the checkbox or the radio button, and use that event to call a Subroutine which sets the focus to your text box. i.e.:
Basic checkbox:
<input type="checkbox" Name="chkBox" onclick ="CallSetFocus">
And the function:
<SCRIPT LANGUAGE="VBScript">
<!--
Public Sub
frmForm.txtTextBox.focus
End Sub
// -->
</SCRIPT>

This sets the focus to txtTextBox when chkBox is clicked on.

Collapse -

HTML - VB Script - Java

by vhansen86 In reply to HTML - VB Script - Java

The java script idea actually worked better for me. But thanks for your suggestion

Collapse -

HTML - VB Script - Java

by Jay Eckles In reply to HTML - VB Script - Java

You did include "VB Script" in your question title, but if you really want to do this on a public webpage, I recommend you use Javascript. It will work just as well in IE and you won't automatically exclude every non-IE browser out there. Try thisscript:
<form name="formname">
<input type="text" name="textboxname">
<input type="radio" name="r1" value="1" onClick="document.formname.textboxname.focus();return true;">

Good luck.

Jay Eckles
www.jayeckles.com

Collapse -

HTML - VB Script - Java

by vhansen86 In reply to HTML - VB Script - Java

Thanks! Valerie

Collapse -

HTML - VB Script - Java

by vhansen86 In reply to HTML - VB Script - Java

This question was closed by the author

Back to Web Development Forum
5 total posts (Page 1 of 1)  

Related Discussions

Related Forums