LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-10-2003, 10:02 AM   #1
TazLinux
Member
 
Registered: Dec 2002
Location: Phoenix
Distribution: Mandrake 9.2
Posts: 228

Rep: Reputation: 30
Java script


OK, I'm using the onClick command to do two seperate functions in a form.

First it runs check(this form) which runs function check() in the header to verify that all the required fields have a value.

Then it runs value="Processing Form..."; to change the name of the button so people don't click it multiple times.

The problem is that if there is a something in the function check requires the user to edit a value, it still changes the value of the button to "Processing Form"

How can I make the button to change to "Processing Form" ONLY after the function check is complete and everything passed?

Here's the code in the onClick for the submit button


code:-----------------------------------------------------------------------------check(this.form);
value="Processing Form...";

and here's the code in the function Check, placed in the JS header

code:--------------------------------------------------------------------------------function check()
{
form = document.forms[0]

if ( document.forms[0].ContactName.value=="") {
alert("Please enter your name")
document.forms[0].ContactName.focus()
return
}

if ( document.forms[0].Email.value=="") {
alert("Please enter your E-mail address");
document.forms[0].Email.focus();
return;
}

if ( document.forms[0].Department.value=="") {
alert("Please enter your department");
document.forms[0].Department.focus();
return;
}

if ( document.forms[0].Phone.value=="") {
alert("Please enter your Phone Number");
document.forms[0].Phone.focus();
return;
}

document.forms[0].submit()
}--------------------------------------------------------------------------------

Last edited by TazLinux; 07-10-2003 at 10:03 AM.
 
Old 07-10-2003, 10:21 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
you just need to set a false return status for that method.

i've only done this with a single crap vbscript function though....
Code:
  If (pform.BranchNumber.value = "" or (Len(pform.BranchNumber.value) > 6 )) Then
    MsgBox "Branch Number field must contain a value, e.g. 6380", 0, "Validation Error"
    pform.BranchNumber.focus()
    pipcode_form_onsubmit = False
    Exit Function
  End If
where the name of my validation function is pipcode_form_onsubmit
 
Old 07-10-2003, 12:15 PM   #3
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 79
Why can't you just change it at the end of the check function?
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
java script file i/o sailu_mvn Programming 2 03-21-2005 10:31 PM
Java and Java Script Dooley General 2 11-17-2004 08:39 AM
How to use Java in a Shell Script arnneisp Programming 1 07-13-2004 02:18 AM
java script not running? w0000422 Linux - Software 2 01-13-2004 08:03 PM
linux 9 and java script error - premature end of script header sibil Linux - Newbie 0 01-06-2004 04:21 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:58 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration