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

How to pause a save when users clicks save button?

Status
Not open for further replies.

ttrinh

MIS
Jan 21, 2002
93
AU
Hi
How do you stop a save happening when user clicks save button? I have a conditioal set up if users satisfy a condition and clicks on save a new cfm pops up asking for input of data. I want the save to not go ahead unless they fill out the popup cfm.
What I have now is that the new cfm page pops up asking for info to be filled in but the save goes ahead anyway.
here is the line that does that
<input type=&quot;submit&quot; value=&quot;Save&quot; class=&quot;lhsbuttonsave&quot; onclick=&quot;popup=window.open('changePCD.cfm?bin=#attributes.bin#','changePCDbox','width=350,height=190,scrollbars=no,resizable=yes');self.focus();&quot;>

Thanks
 
The simplest way is to have a client-side validation on it...so if they hit the 'save' button when the fields are blank, they get an alert...
An example of client side validation is this:
Code:
<script>
function check() {
if(document.formNAME.fieldNAME.value == &quot;&quot;) {
  alert(&quot;Please enter the field&quot;);
  return false;
}
if(document.formNAME.fieldNAME_2.value == &quot;&quot;) {
  alert(&quot;Please enter the field&quot;);
  return false;
}
...
...
...
} //THIS CLOSES THE TOP OPEN BRACE...
</script>
Any questions?? I have not failed; I merely found 100,000 different ways of not succeding...
 
Sorry I think I should have been clearer.
If a user changes a value in the form then click save I want the popup form to appear and prompt user to put in a reason why that field was changed and the form should not save until they fill out that form or else they can choose to cancel.
currently the form pops up and saves regardless of if the fornm is filled out or not

thanks
 
ttrinh, your missing the point, the technique i showed you will also work in your problem...
You want to make sure that the popup form is not left blank right?? That is what the validation script does...so if in your form, someone changes a field, the popup appears asking for a reason, and if the user tries to submit the popup form blank the alert pops up, so the user has two options, either fill out the popup form so the form can be updated, or click cancel where nothing happens...
Isn't that what you were looking fo?? I have not failed; I merely found 100,000 different ways of not succeding...
 
I would change your submit button on the main page to a simple button (<input type=&quot;button&quot;>) so it does not automatically submit the form. Set an onchange handler for the button that executes a function in the main page that does the following:[ul][li]Checks to see if the popup is necessary;[/li][li]If it is, launches the pop-up window.[/li][/ul]Then, the pop-up window will have another form and a button that executes a function that does the following:[ul][li]Takes the information that the user put in the pop-up form and puts it in a hidden field in the main page;[/li][li]Submits the form on the main page[/li][/ul]All you'd have to do then is put in validation wherever necessary.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top