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!

unable to pass var. to another funtion

Status
Not open for further replies.

london01

Technical User
Jun 13, 2004
18
CA
hello everybody,
I'm not the best at javascript so i though i put the problem here and see what i get. I only copy/pasted part of the code with the problem so to not to confuse the problem.
problem:
bassically when the the user hits the submit button the function formvalidation(thisform)is called. everything in the formvalidation() works except the function doYes()!
the doYes() funtion verifys weather the user selected(radio) yes or no to the agreement.
the doYes() function is called from within formvalidation to keep the code clean but i have a feeling the way i'm sending which radio button was sellected isn't being carried over into the formvalidation() function.
problem areas are indicated by the colorred.

any help u can give me would be greatly appreciated.


function doYes(enter = arg[0].checked, alertbox)
{ if (entry === true)
{ return ture; }
else
{ alert(alertbox);
return false;
}
}


function formvalidation(thisform)
{ with (form1)
{ if (emailvalidation(Email,"Illegal E-mail")==false) {Email.focus(); return false;};
if (emptyvalidation(field_three,"The textfield is empty")==false) {field_three.focus(); return false;};
if (doYes(arg[0].checked,"Sorry - you must sign agreement before sending form")==false) {submit_button.focus(); return false;};
popUp("confirm.html");
return true;
}
}
</script>';
echo '</head>';
echo '<body bgcolor="#CCCCCC" text="#993300">';
echo '<div align="center"> <label> <font size="6">How to save user information</font> </label> </div>';
echo '<form name="form1" action="'.$_SERVER['PHP_SELF'].'" method="post" onsubmit="return formvalidation(this)" >';

echo '<p align="center"> <font size="5">Field 1 ==&gt;:</font>
<input name="Email" type="text" size="30" value="" ></p>';
echo '<p align="center"> <font size="5">Field 2 ==&gt;:</font>
<input name="field_two" type="text" id="Field_two" size="30"> </p>';
echo '<p align="center"> <font size="5">Field 3 ==&gt;:</font>
<input name="field_three" type="text" size="30" > </p>';
echo' <textarea name="agreement_text" cols="70" rows="5" id="agreement_text">test agreement test agreement test agreement test agreement test agreement
test agreement test agreement test agreement test agreement test agreement test agreement test agreement test agreement
test agreement test agreement test agreement test agreement test agreement test agreement test agreement
test agreement test agreement test agreement test agreement test agreement test agreement test agreement test agreement
test agreement test agreement test agreement test agreement test agreement test agreement test agreement test agreement
test agreement test agreement test agreement test agreement test agreement test agreement test agreement </textarea>
<br>I have read and accept this agreement
<input name="agr" type="radio">Yes
<input name="agr" type="radio" checked="checked">No';
echo '<p align="center">
<input name="submit_button" type="submit" id="Submit_button" value="Save button">
<input name="Reset_button" type="reset" id="Reset_button" value="Reset"> </p>';
echo '</form>';
 
some errors:
1. i dont think a variable can be assigned in the functions defenition (enter=args[0].checked)

2. while u have defiedn the areguement as enter its use as entry in the function...

Known is handfull, Unknown is worldfull
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top