Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I make this work, focus setting?

Status
Not open for further replies.

taval

Programmer
Jul 19, 2000
192
GB
I currently have a page with several text boxes with respective buttons i.e.<br><br>&lt;text box1&gt;&lt;button1&gt;<br>&lt;text box2&gt;&lt;button2&gt;<br>&lt;text box3&gt;&lt;button3&gt;<br><br>how do I implement code so that if the text box has the focus i.e. I have clicked on the text box or entered data in that box that the focus goes on the respective button. So that when the return key is pressed the button next to the text box is pressed. I have tried giving focus to the button when the text areas are clicked but this means that I can not type in the text boxes since focus is always given to the button.<br><br>my code currently looks something like this:<br><br>---------------------------------------------------<br><br><br>&lt;HTML&gt;<br>&lt;BODY&gt;<br>&lt;FORM METHOD=&quot;POST&quot;&nbsp;&nbsp;NAME=&quot;login&quot;&nbsp;&nbsp;ACTION=&quot;webdb.asp&quot;&nbsp;&nbsp;onSubmit=&quot;return checkPass()&quot;&gt;<br><br>&lt;TABLE width=600 align = center&gt;<br>&lt;TR&gt;<br>&lt;TD BGCOLOR=#CCCCCC&gt;<br>&lt;font face=&quot;Arial,Helvetica&quot;&gt;&lt;font size=+2&gt;BackPocket Database&lt;/font&gt;&lt;/font&gt;<br>&lt;/TD&gt;<br>&lt;/TR&gt;<br><br><br>&lt;TR&gt;<br>&lt;TD BGCOLOR=#FFFFCC&gt;<br>List all customers with BackPocket service<br>&lt;/TD&gt;<br>&lt;TD BGCOLOR=#99FF99 align= center&gt;<br>&lt;input name=&quot;Customers&quot; type=&quot;submit&quot; value=&quot;List Customers&quot; onclick=&quot;javascript:gotonectpage(this);&quot;&gt;<br>&lt;/TD&gt;<br>&lt;/TR&gt;<br><br>&lt;TR&gt;<br>&lt;TD BGCOLOR=#FFFFCC &gt; Search query on<br>&lt;select NAME=&quot;CustQuery&quot;&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;option VALUE=&quot;CustID&quot;&gt;Customer ID<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;option VALUE=&quot;CustName&quot;&gt;Customer Name<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;option VALUE=&quot;CustEmail&quot;&gt;Customer E-mail<br>&lt;/select&gt; with value of<br>&nbsp;<br><br>&lt;INPUT TYPE=&quot;text&quot;&nbsp;&nbsp;NAME=&quot;SQLvariable&quot; size=16 onclick=&quot;javascript:customer_button.focus()&quot;&gt;<br>&lt;/TD&gt;<br>&lt;TD BGCOLOR=#99FF99 align= center&gt;<br>&lt;input name=&quot;customer_button&quot; type=&quot;submit&quot; value=&quot;Search&quot; onclick=&quot;javascript:gotonectpage(this);&quot;&gt;<br>&lt;/TD&gt;<br>&lt;/TR&gt;<br><br>&lt;tr&gt;<br>&lt;TD BGCOLOR=#FFFFCC&gt;Search for customers who have not backed-up in &nbsp;<br>&lt;INPUT TYPE=&quot;text&quot;&nbsp;&nbsp;NAME=&quot;days&quot; size=6 maxlength=6 onclick=&quot;javascript:backup_button.focus()&quot;<br>days<br>&lt;/TD&gt; <br>&lt;TD BGCOLOR=#99FF99 align= center &gt;<br>&lt;INPUT name=&quot;backup_button&quot; TYPE=&quot;submit&quot;&nbsp;&nbsp;VALUE=&quot;Search&quot; <br>onclick=&quot;javascript:gotonectpage(this);&quot;&gt;<br>&lt;/TD&gt;<br>&lt;/TR&gt;<br>&lt;/TABLE&gt;<br>&lt;/FORM&gt;<br>&lt;/BODY&gt;<br>&lt;/HTML&gt;<br><br>-----------------------------------------------------------<br><br>I would be grateful for any help given.<br>Thankx<br>
 
?? why do you post twice the same question ???????<br><br>anyway your answer is : you use the onclick event, but you have to use the onchange event <br>onclick=&quot;javascript:button.focus()&quot; means that as soons as you click in the field it loses the focus !!!<br>onchange=&quot;...&quot; means that the field loses the focus only if the value of the field has changed<br>you can also use : onblur (that is fired when the field loses the focus) <br><br><br><br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top