Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / HTML, CSS, Scripts / JavaScript / December 2005



Tip: Looking for answers? Try searching our database.

forms using keyPress onChange to submit or not to submit

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
awebguynow - 30 Dec 2005 00:33 GMT
to submit or not to submit  - that is the question
and I'm going to be designing some lengthy forms, where many of the
fields may be populated with data, and the user may only want to view
it.

In a perfect world, I'd have 2 buttons:  Close   and  Submit - disabled
and Submit would become enabled - immediately - if data was changed.
otherwise the user could click "Close"  and a php script could redirect
(header) to Default pg.

Any articles on this ?   Has any one attempted this ?   have advice ?
Danny - 30 Dec 2005 04:45 GMT
<input ....
onkeypress="this.form.MYSUBMIT.disabled=false;this.onkeypress=null;">

  <input type="submit" disabled name="MYSUBMIT">
 
  afterwards enabling MYSUBMIT, it removes itself, to avoid any
further keypress checks once the typing started, no point checking
each time.

                                       Danny
awebguynow - 30 Dec 2005 05:24 GMT
Thank you for your response.
My only concern is that this may be cumbersome to code with 30+ input
fields.
Is there a good way to apply this to the whole form ?
Thomas 'PointedEars' Lahn - 30 Dec 2005 08:39 GMT
> Thank you for your response.

Which response?

<URL:http://jibbering.com/faq/faq_notes/pots1.html#ps1Post>
<URL:http://www.safalra.com/special/googlegroupsreply/>

> My only concern is that this may be cumbersome to code with 30+ input
> fields.
> Is there a good way to apply this to the whole form ?

The `keypress' event is documented (in MSDN) and tested (in Mozilla/5.0
rv:1.8) to bubble:

 <form ...
   onkeypress="this.elements['MYSUBMIT'].disabled = false;
               this.onkeypress = null;">
   ...
 </form>

<URL:http://msdn.microsoft.com/workshop/author/dhtml/reference/events/onkeypress.asp>

PointedEars
Jasen Betts - 30 Dec 2005 21:02 GMT
> Thank you for your response.
> My only concern is that this may be cumbersome to code with 30+ input
> fields.
> Is there a good way to apply this to the whole form ?

you could apply onkeypress to the <form>,

onkeypress won't help if the user edits the form without using the keyboard.
- you need onchange on the fields too.

you could do a script that loops through the form fields and installs the
handler.

Bye.
  Jasen
Jasen Betts - 30 Dec 2005 07:00 GMT
> to submit or not to submit  - that is the question
> and I'm going to be designing some lengthy forms, where many of the
[quoted text clipped - 7 lines]
>
> Any articles on this ?   Has any one attempted this ?   have advice ?

it doesn't sound like it will give much trouble.

start with submit enabled and disable it using javascript  (so that users
with script turned off can still submit)

give the editable fields an onchange event handler that enables the submit
button

but anyway: what harm is there in always submitting?

Bye.
  Jasen
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.