473,609 Members | 2,296 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

forms using keyPress onChange to submit or not to submit

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 ?

Dec 30 '05 #1
5 2241


<input ....
onkeypress="thi s.form.MYSUBMIT .disabled=false ;this.onkeypres s=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
Dec 30 '05 #2
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 ?

Dec 30 '05 #3
awebguynow wrote:
Thank you for your response.
Which response?

<URL:http://jibbering.com/faq/faq_notes/pots1.html#ps1P ost>
<URL:http://www.safalra.com/special/googlegroupsrep ly/>
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="thi s.elements['MYSUBMIT'].disabled = false;
this.onkeypress = null;">
...
</form>

<URL:http://msdn.microsoft. com/workshop/author/dhtml/reference/events/onkeypress.asp>
PointedEars
Dec 30 '05 #4
On 2005-12-30, awebguynow <i_****@hotmail .com> wrote:
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 ?


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
Dec 30 '05 #5
On 2005-12-30, awebguynow <i_****@hotmail .com> wrote:
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
Dec 30 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
18559
by: Matt | last post by:
I have radio buttons on a form, and when the user makes the selection, it will trigger the event and send the form to the web server and print the selected value. In Case 1, I just use submit button, without any event handling, and it works fine. However, in Case 2, which is what I am trying to do, it has the problem that even when the user clicks the button, it won't show the value automatically. But wait until user selects another...
5
3452
by: Pascal Batzli Jr | last post by:
Hello, I have a strange situation happening on the code below. When I first load the page, as I change any of the three combo boxes I have created, the onchange event is fired and the form should be submitted, but it isn't for some weird reason. However, after I press the ok button, it submits the form, and then the combo boxes start working normally. In IE, everything works fine. I appreciate any help. Thank you. <html>
4
7731
by: David McNerney | last post by:
Would anyone be able to tell me why I get an error in FireFox 1.5.0.1 for MacOSX when I type some text and hit Enter in the following form: <html> <body> <form action="http://example.com" onSubmit="return false;"> <input type="text" name="samplenum" value="" onChange="alert('onChange fired');"> <input type="submit" name="cmd_submit" value="Submit" onClick="return false">
2
6913
by: Richard | last post by:
Hi, I want to have only one button to Upload file but i get Access denied error. Default.aspx.cs: protected void Page_Load(object sender, EventArgs e) { FileUpload1.Attributes.Add("onchange", "document.forms.submit();"); }
3
3580
by: Kathryn Gill | last post by:
I;m having probs with this script. when i click update form the values from the text boxs that javascript updates won't be saved in the data base. Can any1 help? Thanks Kat <script type="text/javascript"> function ptotal(x,z,r,h,g) {
13
1834
by: DDragon | last post by:
ok here is the problem, i have to forms which have values i wish to be added together i can add together the values in one form all right but im having problems with adding the values of the other form to it... ill post the code for you to look at and try to explaine in detail what im trying to do. here is the code (HTML and Javascript so you get the whole picture): Javascript: var gen, lights; var lammount;
14
75477
by: white lightning | last post by:
How to have <select onchange="this.form.submit()"and also a Submit button on one form? I have something like this: <form action="<?php $_SERVER; ?>" method="post" enctype="multipart/form-data" name="form1"> <select onchange="this.form.submit();" name="prod"> <option value="">Select product</option> <option value="12">abc</option>
6
1848
by: Graham | last post by:
I have long thought there is something missing with HTML forms, in that there should be a provision for a form with hidden input fields, with the whole form being hidden, in particular with no submit button that requires clicking. I have a form that, when processed by a Perl CGI script, sends back a 'Thankyou' message to the user, and I then want to tell the user that in a few seconds he will be taken to the next stage of the process,...
3
2195
by: imoddedu | last post by:
In this code, is it do-able to make a form that is a select and if one option is selected, then 2 more forms are displayed? <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html;charset=UTF-8"> <title></title> <style type="text/css"> #submit { display: block;
0
8126
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8563
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8524
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8394
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5507
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4074
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2527
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1656
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1379
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.