Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

error/problem with form submission

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
hi,

i'm using a script in order to prevent multiple record entries if the user clicks the submit button more than once. right now it is not working. i can't figure out what's wrong...

<!--here's my javascript in the $$HTML head field>

<script language=\&quot;JavaScript\&quot;>
var isSubmitted = \&quot;NO\&quot;;
function checkSubmitted() {
if (isSubmitted ==\&quot;NO\&quot;) {
isSubmitted = \&quot;YES\&quot;;
document._add.submit();}
}
</script>

<!--here's my form tag plus my submit tag>

<form action=&quot;stuadd2.cfm&quot; method=&quot;post&quot; name=&quot;add&quot; onSubmit= &quot;return checkSubmitted(add);&quot;>

<input type=&quot;Submit&quot; value=&quot;Add&quot; onClick=&quot;checkSubmitted()&quot;>
 
Are the backslash characters in your code, or did you put them in just to post here. If the former, that is probably your problem. You don't need to escape quotes unless they are inside of a string in javascript. Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard.
 
thanks, i've tried this, but the scripts still does not do what i want it to do
 
I see several problems. First, I'm not absolutely certain that a form name (or any JavaScript object) is allowed to start with a number or an underscore. I know ids can't... Second, you're asking to &quot;return checkSubmitted(add);&quot;. However, functon checkSubmitted has no return statement in it, so it gives an undefined value. In essence, you're saying &quot;return undefined&quot;. Second, telling the computer to submit form &quot;_add&quot; in the checkSubmitted() function is redundant; the form will submit itself unless you tell it &quot;return false&quot;. Third, you said &quot;return checkSubmitted(add);&quot;, but function checkSubmitted takes no parameters. If you only want to check this form, then you don't need any parameters anyway.

Now, those are the problems I see. You might want to actually read the above for your edification. However, if you're in a hurry, the edited code below should work (I don't have time to test it). I just corrected the most obvious problems...

Code:
<!--here's my javascript in the $$HTML head field>

<script language=&quot;JavaScript&quot;> 
var isSubmitted = &quot;NO&quot;;
function checkSubmitted() {
if (isSubmitted ==&quot;NO&quot;) {
isSubmitted = &quot;YES&quot;;
return true; } else {
return false; }
} 
</script>

<!--here's my form tag plus my submit tag>

<form action=&quot;stuadd2.cfm&quot; method=&quot;post&quot; name=&quot;add&quot;>

<input type=&quot;submit&quot; value=&quot;Add&quot; onClick=&quot;return checkSubmitted()&quot;>

Good luck! Let me know if this doesn't work either.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top