Forum Moderators: open
I've got a question for you bods out there.
I'm making a screen for internal use only. I'd like two buttons on a particular screen. The first one is for recalc'ing rates and I'd like it to reload the page which will perform the recalc and the other is for submitting any changes made to the many fields on the page.
Is something like that possible or do I have to submit all the fields to one page, and the redirect based on the button pressed.
HTML +ASP Classic
Thanks
Mick
The first one is for recalc'ing rates and I'd like it to reload the page which will perform the recalc and the other is for submitting any changes made to the many fields on the page.
I don't think you're asking for two different locations, what you want is two actions.
Two ways to approach it, the first would be dependent on Javascript but faster simply because it would do all the heavy lifting client side, the second would be more reliable because it doesn't depend on Javascript to do the work.
As with any accessible app, you build the non-JS dependent one first, then apply JS to enhance the user experience.
1. URL/URI goes directly to your script which outputs the form with blank values.
As you say, one button is a hook by which you reload the form, the other is the hook by which you process the data.
<input type="submit" name="recalc" id="recalc" value="Recalculate">
<input type="submit" name="process" id="process" value="Process Data">
Side note: never name anything in your forms something that may conflict with "reserved words." For example, don't name or ID your buttons submit, location, window, etc. In the above example, the ID's will be used for the Javascript, when you get to it.
2. On submit, your processing script decides whether to recalc and return the form or process the data, something like
If Request.Form("recalc") <> "" Then
'recalc and return to page with submitted values intact
Else If Request.Form("process") <> "" Then
' process form, return success page
Else
' output blank form
End If
3. Once you get it worked out without Javascript, you apply your program logic to JS and do it all client side. This may require populating Javascript arrays and variables as the form loads from your script, which should now be very easy because you already have them "in hand" the first time the page loads.