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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

parameter passing

Status
Not open for further replies.

mickeyg

Technical User
Mar 30, 2001
120
US
Rewriting mycount() to accept a 2nd parameter instead of using a hardcode variable (pwdcount). Logincount is coming back as zero when the email address is filled in.

What am I doing wrong?
TIA,
Mickey

Caller...
function valdmlogin() {
var myform = document.forms[0];
loginErrorMsg = "";
logincount = 0;

if (myform.email) {
mycount(myform.email.value,logincount);
alert('logincount is ' + logincount);
}
}

Child function...
function mycount(myfield, mycounter) {
// myfield - field to check for value
// mycounter - optional counter field to increment
var mycounter = mycounter || 'pwdcount'; // if mycounter is null default it
if (myfield != "") {
return mycounter++;
}
}
 
you have to set logincount = the function mycount

like such:
Code:
    if (myform.email) {
        [!]logincount =[/!] mycount(myform.email.value,logincount);
        alert('logincount is ' + logincount);
    }


<.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top