This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes Applying onChange and Short Cut key in a Submit button Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Applying onChange and Short Cut key in a Submit button" Watch "Applying onChange and Short Cut key in a Submit button" New topic
Author

Applying onChange and Short Cut key in a Submit button

Nitin Kumar
Greenhorn

Joined: Apr 18, 2005
Posts: 29
1 For a submit button in a form I have two requirments
a) Apply a short cut key for the submit button ( say [Alt N] )
b) Submit the form using a JavaScript function. i.e the JS function has following piece of code
function myFun {
document.edit.submit();
}

I know two ways of implementing a submit button
i) Using input
<input type="submit" name = "save" value=" Save" >
ii) Using button
<button type="submit" accesskey="n" name="submit">Save</button>

Problem is that when I use i) , requirment a) doesn't work and when I use ii) , requirment b) doesn't work.
Is there any way out two fulfil both the requirments at the same time?

2 In a edit form there are too many text field.There is a submit button to save the changes done in the page.When this page is loaded all the text fields are prepopulated.I want that when the page is loaded , Save button should be disabled and it should get enabled only when any value is modified. One way of doing this is to write a JavaScript function to enable the button and this JS function will be called on onBlur event of EACHtext field.
Since there are large number of such pages in which modifucation need to be done , is there any other way to achieve the requirment in which I need not change ALL the text field.

These Html pages are generated using JSP.
[ June 07, 2006: Message edited by: NitinK Kumar ]
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
you can not name your btn submit, name it something else such as btnSubmit.

When you name it submit, it overwrites the submit method of the form.

Eric
Nitin Kumar
Greenhorn

Joined: Apr 18, 2005
Posts: 29
Thanks Eric for the solution...
 
 
subject: Applying onChange and Short Cut key in a Submit button
 
Similar Threads
Form is submitting more than once
h:commandLink and onsubmit
invoke submit on hitting enter key
"enter key" button focus ?
Submit button problem