Wrox Home  
Search P2P Archive for: Go

  Return to Index  

javascript thread: ONFOCUS Question


Message #1 by "Melinda Savoy" <savoym@h...> on Mon, 9 Dec 2002 13:22:08
Question 1:  Yes.  It would definitely help if you have your table between the
script tags.

Question 2:  The following code should work...

<INPUT type="text" id=textbox onkeypress="CheckEnter()">

<SCRIPT Language="Javascript">
function CheckEnter()
{
  // 27 is the ASCII 
  // Code for the Escape Key

  if (event.keyCode == 27)    
  {
    FormName.submit();
  }
}
</SCRIPT>


But your data may not be sent to the server if you do not have the Textboxes,
checkboxes, etc wrapped between FORM Tags.
On Mon, 9 Dec 2002 14:06:04 Melinda Savoy <savoym@h...> wrote:

> Thank you for the response. 2 Questions if you
> do not mind:
> 
> 1. I am calling the "strAllProducts_table"
> within the FORM tags however 
> my table is being buillt outside of the form
> tags is that why this does 
> not work?
> 
> 2. Can you please direct me to some javascript
> code for what you're 
> suggesting regarding the FORM.Submit() method
> for the keypress?  
> 
> Your time is appreciated.  Thanks again!!
> 
> 
> > If I am understanding you correctly all you
> need to do is insure that 
> your
> Textbox (that is dynamically built in your
> Table) is contained between the
> FORM Tags.  The form tags should cause the
> information to be sent back to 
> the
> server when the user presses the enter key.
> 
> If that doesn't work, then you can always write
> javascript code that 
> calls the
> FORM.Submit() method when keypress detects an
> enter key for the text box.
> 
> On Mon, 9 Dec 2002 13:22:08 Melinda Savoy 
> wrote:
> 
> > When a user is tabbing through my form and
> gets
> > to a textbox field in a 
> > dynamically created table, where they can
> > change the value in the textbox 
> > I want the CONTINUE button at the bottom of
> the
> > form to get FOCUS because 
> > my keyboard users are pressing the enter key
> on
> > their keyboard thinking 
> > they are going to go to the next page.
> > 
> > How do I accomplish this?  Any help or
> > direction would be appreciated.
> > 
> > Here is the code where my textbox(es) exist:
> > 
> > strAllProducts_table = ""
> > 
> > strAllProducts_table = strAllProducts_table &
> > "" & vbCRLF
> > strAllProducts_table = strAllProducts_table &
> > "Remove Resource" & vbCRLF
> > strAllProducts_table = strAllProducts_table &
> > "Resource Category" & vbCRLF
> > strAllProducts_table = strAllProducts_table &
> > "Resource Type" & vbCRLF
> > strAllProducts_table = strAllProducts_table &
> > "Resource:" & vbCRLF
> > strAllProducts_table = strAllProducts_table &
> > "Qty.:" & vbCRLF
> > strAllProducts_table = strAllProducts_table &
> > "Suggested Donation Amt.:" & vbCRLF
> > strAllProducts_table = strAllProducts_table &
> > "" & vbCRLF
> > 
> > '***** Setup the variable to ensure empty
> > before populating. *****
> > strcustAllProducts = ""
> > '***** Start loop for all products associated
> > with the customer_id. *****
> > Do While Not rs.EOF
> > strAllProducts_table = strAllProducts_table &
> > "" & vbCRLF
> > strAllProducts_table = strAllProducts_table &
> > "" & vbCRLF
> > strAllProducts_table = strAllProducts_table &
> > "" & trim(rs
> > ("product_category")) & "" & vbCRLF
> > strAllProducts_table = strAllProducts_table &
> > "" & trim(rs
> > ("product_type")) & "" & vbCRLF
> > strAllProducts_table = strAllProducts_table &
> > "" & trim(rs
> > ("product_description")) & "" & vbCRLF
> > strAllProducts_table = strAllProducts_table &
> > "" & vbCRLF
> > strAllProducts_table = strAllProducts_table &
> > "" & rs
> > ("product_donation_amt") & "" & vbCRLF
> > strAllProducts_table = strAllProducts_table &
> > "" & vbCRLF
> > 
> > '***** Set variable to a comma delimited
> string
> > for using in the updated 
> > stored procedure above. *****
> > strcustAllProducts = strcustAllProducts &
> > rs("product_id") & ", "
> > iCounter = iCounter + 1
> > rs.MoveNext
> > Loop
> > strAllProducts_table = strAllProducts_table &
> > "" & vbCRLF
> > 
> > '***** Remove the comma at the end of the
> last
> > record. *****
> > strcustAllProducts = left(strcustAllProducts,
> > len(strcustAllProducts) - 
> > 2) & " "
> > End If
> > rs.Close
> > 
> 
> 


  Return to Index