colonelblue
asked on
Confirm button still updates changes even after cancel is clicked.
I have a form that has an alert when submitted that says:
Submit? Alert Box with
"OK" or "Cancel" Button"
"OK" goes through , submits and alerts "Submitted".
Cancel Alert Box
When clicked says "Not Submitted" but still submits the edit despite the cancel.
Please help.
Thanks in advance.
<script type="text/javascript">
<!--
function confirmation() {
var answer = confirm("Submit ?")
if (answer){
alert("Updated Succesfully")
parent.window.location = "index2.asp";
}
else{
alert("Not Submitted!")
parent.window.location = "index.asp";
}
}
//-->
</script>
Submit? Alert Box with
"OK" or "Cancel" Button"
"OK" goes through , submits and alerts "Submitted".
Cancel Alert Box
When clicked says "Not Submitted" but still submits the edit despite the cancel.
Please help.
Thanks in advance.
<script type="text/javascript">
<!--
function confirmation() {
var answer = confirm("Submit ?")
if (answer){
alert("Updated Succesfully")
parent.window.location = "index2.asp";
}
else{
alert("Not Submitted!")
parent.window.location = "index.asp";
}
}
//-->
</script>
Is this what you are looking for?
Are you calling the function from the form like:
<script type="text/javascript">
<!--
function confirmation() {
var answer = confirm("Submit ?")
if (answer){
alert("Updated Succesfully")
parent.window.location = "index2.asp";
}
else{
alert("Not Submitted!")
parent.window.location = "index.asp";
return false;
}
}
//-->
</script>
Are you calling the function from the form like:
<form action="whatever" onsubmit="return confirmation()">
ASKER
Hello guys that still doesn't seem to work.
This is what I have at the bottom of the form:
<script type="text/javascript">
<!--
function confirmation() {
var answer = confirm("Submit ?")
if (answer){
alert("Updated Succesfully")
parent.window.location = "index2.asp";
}
else{
alert("Not Submitted!")
parent.window.location = "index.asp";
return false;
}
}
//-->
</script>
<input type="button" class="Cancel_Button" onclick="parent.location=' index.asp' " value='Cancel & Close' /></td>
<td width="25%" align="left"><input name="Update" type="submit" class="go_button" id="Update" onclick="confirmation()" value="Update" /></td>
</tr>
</table>
<br />
<input type="hidden" name="MM_update" value="form1" />
<input type="hidden" name="MM_recordId" value="<%= RSRockers.Fields.Item("ID" ).Value %>" />
</form>
</td>
Thank you.
This is what I have at the bottom of the form:
<script type="text/javascript">
<!--
function confirmation() {
var answer = confirm("Submit ?")
if (answer){
alert("Updated Succesfully")
parent.window.location = "index2.asp";
}
else{
alert("Not Submitted!")
parent.window.location = "index.asp";
return false;
}
}
//-->
</script>
<input type="button" class="Cancel_Button" onclick="parent.location='
<td width="25%" align="left"><input name="Update" type="submit" class="go_button" id="Update" onclick="confirmation()" value="Update" /></td>
</tr>
</table>
<br />
<input type="hidden" name="MM_update" value="form1" />
<input type="hidden" name="MM_recordId" value="<%= RSRockers.Fields.Item("ID"
</form>
</td>
Thank you.
The attached will keep the browser from redirecting, but not sure if that is what you are looking for
<script type="text/javascript">
function confirmation() {
var answer = confirm("Submit ?")
if (answer){
alert("Updated Succesfully")
parent.window.location = "index2.asp";
}
else{
alert("Not Submitted!")
return false;
parent.window.location = "index.asp";
}
}
</script>
Good point why are you redirecting on cancel it is this stopping the return false; working
ASKER
I must be doing something wrong.
Regardless of selecting cancel to the Update Alert Box after clicking update, the record is changed.
What I hoped for was to let the user ascertain on whether they want to make the change they had just did before adding it to the database. If they say "cancel", nothing gets updated. If they are certain then it updates. But is seems to update regardless.
Regardless of selecting cancel to the Update Alert Box after clicking update, the record is changed.
What I hoped for was to let the user ascertain on whether they want to make the change they had just did before adding it to the database. If they say "cancel", nothing gets updated. If they are certain then it updates. But is seems to update regardless.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Open in new window