This topic is locked

Reset Button

7/5/2007 11:37:09 AM
PHPRunner General questions
D
drh author

Hi forum members,

I have an application written in PHPR3.0. I am trying to bring up an alert/confirm box if the user presses the "Reset" button on the add and/or edit page.
If the user confirms that they really do want to reset, they press ok and the fields clear as normal. However, if the user decides that they really did not want to reset, they can press cancel in which case the field contents remain and the add page is returned so they can save.
Seems simple enough, I just am having difficulty getting it to work. I am currently trying to use javascript to add this functionality. If anyone has examples or thoughts, I would appreciate them.
Thanks,

Dave

D
drh author 7/5/2007

Hi all,
I have the following coded in my _add.php program under "buttons".
<input class=button type=reset value="Reset" onclick="java script: confirm_reset()">
Then I have a javascript function in a custom javascript program in the ./include directory.

The contents of which look like this:
<script type="text/javascript">

function confirm_reset(){

input_box=confirm("Click OK to Continue or Cancel to go back!");

if (input_box==true){

alert("got to here");

addform.backtolist.value="yes";

document.addform.submit();

}

else

{

}

}

</script>
When I click OK, I get the alert box, but I am not sure how to get the user back to the add page with the contents intact. The way it is right now, if I click OK or Cancel, the contents of the fields is removed.
Thanks,

Dave