By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,568 Members | 1,688 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,568 IT Pros & Developers. It's quick & easy.

How do I read the Value of the submit Button

P: n/a
jb


this is what I have in my funtion, but returns undefind value?

if (document.forms[0].submit.value=="Cancel") {
return true;
}


Jul 20 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a


jb wrote:
this is what I have in my funtion, but returns undefind value?

if (document.forms[0].submit.value=="Cancel") {
return true;
}


Give the button a name
<input type="submit" name="submitButton"
then you can read
document.forms[0].elements.submitButton.value
--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 20 '05 #2

P: n/a
jb
I tryed what you gave me, still same results here my function, it all works
except for the part that checks the submitBut value; always reture an
undefined value.

function ValidateData() {
var CanSubmit = false;

// this is the part I'am have trouble with

if (document.forms[0].elements.SubmitBut.value=='Cancel') {
return true;
}

//----------------------------

CanSubmit = ForceEntry(document.forms[0].fFirstName,"Please
supply a first name.");

if (CanSubmit) CanSubmit =
ForceEntry(document.forms[0].fLastName,"Please supply a last name.");
if (CanSubmit) CanSubmit = ForceEntry(document.forms[0].fTitle,"Please
supply a title.");
if (CanSubmit) CanSubmit =
ForceEntry(document.forms[0].fPhone1,"Please supply a phone number.");
if (CanSubmit) CanSubmit = isEmail(document.forms[0].fEmail1,"Please
supply valid email address.");
if (CanSubmit) CanSubmit =
ForceEntry(document.forms[0].fOrgAddress1,"Please supply an office
address.");
if (CanSubmit) CanSubmit =
ForceEntry(document.forms[0].fOrgCity,"Please supply an office city.");
if (CanSubmit) CanSubmit =
ForceEntry(document.forms[0].fOrgState,"Please supply an office state.");
if (CanSubmit) CanSubmit =
isZipCode(document.forms[0].fOrgZipCode,"Please supply an office zip
code.");
if (CanSubmit) CanSubmit =
ForceEntry(document.forms[0].fOrgCountry,"Please supply your office
country.");
if (CanSubmit) CanSubmit =
ForceEntry(document.forms[0].fPassword,"Please supply a password.");
if (CanSubmit) CanSubmit =
ForceEntry(document.forms[0].fPassword2,"Please supply retype password.");
if (CanSubmit) CanSubmit =
CheckPassword(document.forms[0].fPassword,document.forms[0].fPassword2,"Plea
se check or retype password.");
return CanSubmit;
}

"Martin Honnen" <Ma***********@t-online.de> wrote in message
news:3f********@olaf.komtel.net...


jb wrote:
this is what I have in my funtion, but returns undefind value?

if (document.forms[0].submit.value=="Cancel") {
return true;
}


Give the button a name
<input type="submit" name="submitButton"
then you can read
document.forms[0].elements.submitButton.value
--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.