Mike Waller
asked on
print dialog window on form submit button
I have a javascript for a form that handles errors for things such as empty fields, unchecked radio buttons, etc. However, on the submit button, if all criteria is met, then I need the print dialog window to come up before going to the action page. The print dialog should print the form pages. Any ideas how I can adjust what I have? I also tried adding onClick="window.print()" to the submit button but it didn't work. Again, the dialog has to appear only if all criteria is met in javascript below.
<script language="JavaScript">
<!--//
function valwpp(thisform) {
myOption1 = -1;
for (i=0; i<thisform.newapp.length; i++) {
if (thisform.newapp[i].checke d) {
myOption1 = i;
}
}
if (myOption1 == -1) {
alert("Please select either a New Application or Re-entry. (#1)");
return false;
}
if (document.formdata.licfnam e.value == "")
{
alert("Please your first name. (#2)");
document.formdata.fname.fo cus();
return false;
}
return;
}
// -->
</script>
<form onSubmit="return valwpp(this)" action="formdata.cfm" name="formdata" method="post">
[fields]..
<input type="submit" value="Submit/Print" name="submit" src="images/submit.jpg" >
</form>
<script language="JavaScript">
<!--//
function valwpp(thisform) {
myOption1 = -1;
for (i=0; i<thisform.newapp.length; i++) {
if (thisform.newapp[i].checke
myOption1 = i;
}
}
if (myOption1 == -1) {
alert("Please select either a New Application or Re-entry. (#1)");
return false;
}
if (document.formdata.licfnam
{
alert("Please your first name. (#2)");
document.formdata.fname.fo
return false;
}
return;
}
// -->
</script>
<form onSubmit="return valwpp(this)" action="formdata.cfm" name="formdata" method="post">
[fields]..
<input type="submit" value="Submit/Print" name="submit" src="images/submit.jpg" >
</form>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Like this:
<script language="JavaScript">
<!--//
function valwpp(thisform) {
myOption1 = -1;
for (i=0; i<thisform.newapp.length; i++) {
if (thisform.newapp[i].checke
myOption1 = i;
}
}
if (myOption1 == -1) {
alert("Please select either a New Application or Re-entry. (#1)");
return false;
}
if (thisform.licfname.value == ""){
alert("Please your first name. (#2)");
thisform.fname.focus();
return false;
}
window.focus();
window.print();
return true;
}
// -->
</script>