html_code_clinic thread: HELPKeeping focus on a specific button when cursor is in any text box
Rod,
Thanks for the reply. I have written this page in ASP and I have tried
using the onBlur unfortunately, this has proved to be unsuccessful
probably because I am using it wrong. Let me try to explain why I stated
that when the user tabs over to the first textbox in my dynamic table the
focus is on a button prior to building the table because when the value
in the textbox is highlighted the user presses the enter key on her
keyboard and because the focus is on the button is launches and causes an
error. I know I'm missing something. Thanks for the time anyway.
> A button can be set to receive the return button on your keyboard,
So that when the keyboard return key is hit that button is depressed, =
which I suppose is much like having focus for a button.
This is done by catching the keypress and is explained at:
http://www.p2p.wrox.com/archive/beginning_vb/2001-05/57.asp
Have you considered using 'OnBlur', when the user leaves the textbox you =
can set the focus to where you like, or depress the button in code if =
you like.
But as far as keeping the focus on a button when a user is in a text =
box.
No, The text box has the focus.
Is this a form being submitted as submit buttons are default on 'return' =
keypress automatically.
Rod
-----Original Message-----
From: Melinda Savoy [mailto:savoym@h...]=20
Sent: Friday, 6 December 2002 12:43 AM
To: HTML Code Clinic
Subject: [html_code_clinic] HELPKeeping focus on a specific button when =
cursor is in any text box
Hey guys,
Quick question please. I have a form whereby I am building a table=20
dynamically that contains a textbox in each row for the qty that a=20
customer may want. Obviously, this table is created in a do while loop. =
=20
My problem revolves around keyboard users and not mouse users whereby=20
when they tab over to the textbox that already has a default value of =
"1"=20
in it the focus is placed on a button earlier in the page and then after =
the user changes the value from "1" to anything else they depress the=20
enter key and get an error. I've tried creating tabindexes but that =
does=20
not seem to handle my focus problem though I had tried the ONCLICK event =
which for a keyboard user proved pointless. Since I am having to deal=20
with keyboard users as well as mouse users I need a way that each row=20
that has this qty textbox is tabbed to that another specific button,=20
CONTINUE, receives the focus. Here is the code where I am creating the=20
table and any help or direction would be appreciated, thank you:
'***** Build the Products table associated with this customer and where=20
user can add or delete product. *****
If Not rs.EOF Then
strfname =3D trim(rs("customer_fname"))
strlname =3D trim(rs("customer_lname"))
strAllProducts_table =3D "<TABLE width=3D'575' align=3D'left' =
border=3D'1'=20
cellpadding=3D'2' cellspacing=3D'0'>"
strAllProducts_table =3D strAllProducts_table & "<tr>" & vbCRLF
strAllProducts_table =3D strAllProducts_table & "<th><font =
face=3D'arial'=20
size=3D'2'>Remove Resource</font></th>" & vbCRLF
strAllProducts_table =3D strAllProducts_table & "<th><font =
face=3D'arial'=20
size=3D'2'>Resource Category</font></th>" & vbCRLF
strAllProducts_table =3D strAllProducts_table & "<th><font =
face=3D'arial'=20
size=3D'2'>Resource Type</font></th>" & vbCRLF
strAllProducts_table =3D strAllProducts_table & "<th><font =
face=3D'arial'=20
size=3D'2'>Resource:</font></th>" & vbCRLF
strAllProducts_table =3D strAllProducts_table & "<th><font =
face=3D'arial'=20
size=3D'2'>Qty.:</font></th>" & vbCRLF
strAllProducts_table =3D strAllProducts_table & "<th><font =
face=3D'arial'=20
size=3D'2'>Suggested Donation Amt.:</font></th>" & vbCRLF
strAllProducts_table =3D strAllProducts_table & "</tr>" & vbCRLF
'***** Setup the variable to ensure empty before populating. *****
strcustAllProducts =3D ""
'***** Start loop for all products associated with the customer_id. =
*****
Do While Not rs.EOF
strAllProducts_table =3D strAllProducts_table & "<tr>" & vbCRLF
strAllProducts_table =3D strAllProducts_table & "<td
align=3D'center'=20
valign=3D'middle'><input type=3D'checkbox' =
name=3D'delete_checked_product'=20
value=3D'" & rs("product_id") & "'></td>" & vbCRLF
strAllProducts_table =3D strAllProducts_table & "<td
align=3D'left'=20
valign=3D'middle' value=3D'" & rs("product_category") & "'=20
name=3D'product_category'><font face=3D'arial' size=3D'2'>" & trim(rs
("product_category")) & "</font></td>" & vbCRLF
strAllProducts_table =3D strAllProducts_table & "<td
align=3D'left'=20
valign=3D'middle' value=3D'" & rs("product_type") & "'=20
name=3D'product_type'><font face=3D'arial' size=3D'2'>" & trim(rs
("product_type")) & "</font></td>" & vbCRLF
strAllProducts_table =3D strAllProducts_table & "<td
align=3D'left'=20
valign=3D'middle' value=3D'" & rs("product_id") & "'=20
name=3D'product_selected'><font face=3D'arial' size=3D'2'>" & trim(rs
("product_description")) & "</font></td>" & vbCRLF
strAllProducts_table =3D strAllProducts_table & "<td
align=3D'center'=20
valign=3D'middle'><input type=3D'text' name=3D'product_qty' size=3D'5'=20
maxlength=3D'5' value=3D'" & rs("product_qty") & "' =
onclick=3D'submit_cont.focus
();'></td>" & vbCRLF
strAllProducts_table =3D strAllProducts_table & "<td
align=3D'right'=20
valign=3D'middle'><font face=3D'arial' size=3D'2'>" & rs
("product_donation_amt") & "</font></td>" & vbCRLF
strAllProducts_table =3D strAllProducts_table & "</tr>" & vbCRLF
'***** Set variable to a comma delimited string for using in the updated =
stored procedure above. *****
strcustAllProducts =3D strcustAllProducts & rs("product_id")
& ", "
iCounter =3D iCounter + 1
rs.MoveNext
Loop
strAllProducts_table =3D strAllProducts_table & "</table>" & vbCRLF
'***** Remove the comma at the end of the last record. *****
strcustAllProducts =3D left(strcustAllProducts, len(strcustAllProducts) =
-=20
2) & " "
End If
rs.Close=20
---
Change your mail options at http://p2p.wrox.com/manager.asp or=20
to unsubscribe send a blank email to =