This topic is locked
[SOLVED]

 How to add Javascript confirm

5/11/2010 1:28:41 PM
PHPRunner General questions
B
billprice author

Hi,

I need to add a Javascript confirm box whenever a user clicks on the Save button in the Add New Record page.

The options would be 'Are you sure you want to add a new entry?' and 'Cancel'.
I need it to work similar to the Delete button where it asks to confirm.
Any help would be appreciated.
Thanks,

Bill

A
ann 5/12/2010

Bill,
To add a confirm box you should change the "Save" button html-code. Go to the HTML mode of the Add page on Visual Editor tab

See my changes (bold) below:

{BEGIN save_button}

<span class=buttonborder><input class=button type=button value="Save" onclick="confirmation()"></span>

{END save_button}


Thereafter add the JavaScipt event at the end of the document.

Here is just a sample:

<script>

function confirmation() {

var answer = confirm("Are you sure?")

if (answer) {editform1.submit()}

else {window.location.href='TableName_list.php?a=return'}

}

</script>
B
billprice author 5/12/2010



Bill,
To add a confirm box you should change the "Save" button html-code. Go to the HTML mode of the Add page on Visual Editor tab

See my changes (bold) below:
Thereafter add the JavaScipt event at the end of the document.

Here is just a sample:

<script>

function confirmation() {

var answer = confirm("Are you sure?")

if (answer) {editform1.submit()}

else {window.location.href='TableName_list.php?a=return'}

}

</script>



Thanks you so much for your assistance.

I used your sample code and everything is working great!

Bill