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

Two Submit Buttons on a form

Status
Not open for further replies.

Joelo

MIS
Sep 27, 2003
61
0
0
Please I have a form with two submit buttons. Each to cause the user to do different thing (Save Form and Submit Form)
On clicking the SAVE Form Button...Information entered by the user is saved for editing later and On clicking
the SAVE Form Button...Information entered by the user is validated and submitted into the database


Response.Write "<form name=""device"" onSubmit=""return checkrequired(this)"" action=""devicedatabaseform.asp"" method=""post"">" & VbCrLf

...................................
..................................
...................................

response.write(" <td align=left><input type=""submit"" name=""SAVE"" value=""Click Here to SAVE FORM"" onclick=""parent.passDate(this.form.x_TESTDATE.value);""></td>")
response.write(" <td align=left><input type=""submit"" name=""Action"" value=""Click Here to SUBMIT FORM"" onclick=""parent.passDate(this.form.x_TESTDATE.value);""></td>")


response.write(" </form>")

thanks
 
submitting forms using buttons thread333-822006
two action on a form thread333-821017



___________________________________________________________________
[sub]
The answer to your ??'s may be closer then you think.
Check out Tek-Tips knowledge bank by clicking the FAQ link at the top of the page faq333-3811
[/sub]
 
Please How do I call "return checkrequired(this)" function to validate info on the b/4 the form is submitted?


thanks
 
<form name="form1" onSubmit="return checkrequired(this)">

<form name="form2" onSubmit="return checkrequired(this)">
 
I am sorry about that I want to call "return checkrequired(this)" function to validate info on the b/4 the form is submitted only when submit button is clicked on
 
please could somebody tell me what I am doing wrong...I can't seem to get it setaction(this.value) function to work with the same onClick event as return checkrequired(this) function

<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function checkrequired(which) {
var pass=true;
if (document.images) {
for (i=0;i<which.length;i++) {
var tempobj=which.elements;
if (tempobj.name.substring(0,0)=="") {
if (((tempobj.type=="text")&&
tempobj.value=='')||(tempobj.type.toString().charAt(0)=="s"&&
tempobj.selectedIndex==0)) {
pass=false;
break;
}
}
}
}
if (!pass) {
shortFieldName=tempobj.name.substring(2,60).toUpperCase();
alert("Please Enter the Required Information for "+shortFieldName+" field.");
//tempobj.focus();
return false;
}
else
return true;
}

function setaction(strVal){
if (strVal == "Click Here to SAVE FORM"){
document.device.action="devicedatabaseform.asp";
alert("You are about to Save your Information");
document.device.submit();
}
else if (strVal == "Click Here to SUBMIT FORM"){
document.device.action="devicedatabaseform.asp";
alert("You are about to Submit your Information");
document.device.submit();
}
else {
alert("a error occured!")
}
}

// End -->
</script>
 
please could somebody tell me what I am doing wrong...I can't seem to get it setaction(this.value) function to work with the same onClick event as return checkrequired(this) function

<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function checkrequired(which) {
var pass=true;
if (document.images) {
for (i=0;i<which.length;i++) {
var tempobj=which.elements;
if (tempobj.name.substring(0,0)=="") {
if (((tempobj.type=="text")&&
tempobj.value=='')||(tempobj.type.toString().charAt(0)=="s"&&
tempobj.selectedIndex==0)) {
pass=false;
break;
}
}
}
}
if (!pass) {
shortFieldName=tempobj.name.substring(2,60).toUpperCase();
alert("Please Enter the Required Information for "+shortFieldName+" field.");
//tempobj.focus();
return false;
}
else
return true;
}

function setaction(strVal){
if (strVal == "Click Here to SAVE FORM"){
document.device.action="devicedatabaseform.asp";
alert("You are about to Save your Information");
document.device.submit();
}
else if (strVal == "Click Here to SUBMIT FORM"){
document.device.action="devicedatabaseform.asp";
alert("You are about to Submit your Information");
document.device.submit();
}
else {
alert("a error occured!")
}
}

// End -->
</script>

response.write(" <input type=""submit"" name=""Action"" value=""Click Here to SUBMIT FORM"" onclick=""return checkrequired(this.form); parent.passDate(this.form.x_TESTDATE.value); setaction(this.value);""></td>")
 
this wont work.

Code:
response.write("  <input type=""submit"" name=""Action"" value=""Click Here to SUBMIT FORM"" onclick=""return checkrequired(this.form); parent.passDate(this.form.x_TESTDATE.value); setaction(this.value);""></td>")

it will not stop the form submitting.

use the code I suggested earlier:
Code:
<form name="form1" onSubmit="return checkrequired(this)">

<form name="form2" onSubmit="return checkrequired(this)">
if the function returns false the form will not send.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top