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++;
}
}
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++;
}
}