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!

Confirmation and redirecting based on answer... 1

Status
Not open for further replies.

WildWest

Programmer
Apr 2, 2002
111
0
0
US
Hi All. I have an online form with text boxes, other form fields, and a submit button. When a user clicks the final submit button, I need a message box to say "Would you like to mark this record as complete?" - with both yes/no buttons on it. When 'yes' is selected, it loads 'complete.cfm'. When 'no' is selected, it loads 'not_complete.cfm'.

I'm using the following but it doesn't seem to pick up all the variables from the previous form... IE: #form.varname#, etc... Please advise.

-------------------------
<SCRIPT LANGUAGE=&quot;JavaScript&quot;>
<!--
function confirmRedirect(prompt, okURL, cancelURL)
{
var confirmResult;

// ask the user to chose either OK or Cancel
confirmResult = confirm(prompt);

// switch to a new URL based on the user's choice
if (confirmResult) {
window.location = okURL;
} else {
window.location = cancelURL;
}
}
// -->
</SCRIPT>
.
.
.
.

<form action=&quot;finish.cfm&quot; method=&quot;POST&quot;>
.
.
.
.
<INPUT TYPE=&quot;button&quot; VALUE=&quot;Submit Finished Form&quot; onClick=&quot;confirmRedirect('Select Yes to mark this as complete!','complete.cfm','not_complete.cfm')&quot;>

-------------------------

Please advise if you can... Thanks a bunch!!!! It kinda urgent!
 
The form fields are not present because the form is not being submmited I dont have the exact code but you need to change the action of the form to point to where ever!

HTH
 
Change your button to type submit and in your form tag add the call to the confirmation function. Add 'this' to the function call to give you easy reference to the form and set the action in your if statement. This should work but I didn't test it.


<SCRIPT LANGUAGE=&quot;JavaScript&quot;>
<!--
function confirmRedirect(frm,prompt)
{
var confirmResult;

// ask the user to chose either OK or Cancel
confirmResult = confirm(prompt);

// switch to a new URL based on the user's choice
if (confirmResult) {
frm.action = 'complete.cfm';
} else {
frm.action = 'not_complete.cfm';
}
}
// -->
</SCRIPT>
.
.
.
.

<form action=&quot;finish.cfm&quot; method=&quot;POST&quot; onSubmit=&quot;return confirmRedirect(this,'Select Yes to mark this as complete!')&quot;>
.
.
.
.
<INPUT TYPE=&quot;submit&quot; VALUE=&quot;Submit Finished Form&quot; >

Hope this Helps
RnK
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top