Simon Jakesch wrote:
> hi,
>
> maybe this is a kinda stupid question but at the moment i can't see a
> way out of this situation.
> i need to check the entry of a specific formfield and do something
> depending on the value of this field. the problem is: i can't do this
> through javascript because the action of the jsp part, which should take
> place if the form is submitted, is different depending on the formfield
> entry. shematically looks like below. i'm sure there is a very easy
> answer to this problem i just can't find it at th moment.
>
> thanks for any help,
> bye,
> simon
>
> if (formsubmit == true){
> if (text-field-inform == 1){ do jspaction1 }
> else{ do jspaction2 }
> }
>
The problem you are having is *when* actions are processed. In particular, JSP
actions are executed only when you are generating the page (or, if you submit to a
JSP page, when the response page is being generated). There is no way, from
JavaScript, to affect the JSP logic used to generate the *current* page, because
the entire page has been completed before the user begins to interact with it (and
therefore executes your JavaScript code).
You can do this indirectly, however, by using an <input type="hidden"> variable in
your form. Use the JavaScript code to set this variable to some sort of code
value that you use (when receiving the submission) to decide what to do in the JSP
page.
Craig McClanahan
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
FAQs on JSP can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html