Changing target of a submitted form

H

Husain

Hello.

I have a form in which after submission displays several messages
depending on what the user has inputted. The form goes to a
AddCompanyHandle.jsp page where the input is verified and added into
the database.


I have a different jsp page called Message.jsp which displays the
appropriate message in a separate frame. Thus, an example of which
message is to be displayed is shown below. (This code will be in
AddCompanyHandle.jsp)

<jsp:forward page="Message.jsp">
<jsp:param name="Msg" value="Please enter valid tel/fax number. Only
digits please" />
</jsp:forward>

Thus Message.jsp will run getParameter and display the message in a
separate frame called MessageFrame. (In order to do that, I already
set the target of the form to MessageFrame).

However, if the form is correctly filled and completed, I would like
to redirect the page to the main page. I used
response.sendRedirect("Main.jsp"). However due to the target which I
already set in the form, this page loads in the MessageFrame which is
not what I want. I want it to load in the MainFrame if and only if the
form is correctly filled.

So, my question is, is there a way where I can change the target of
the form after it is submitted and sens to a jsp page to be handled?

Thank you for your kind help.
 
B

Bart Van der Donck

Husain said:
I have a form in which after submission displays several messages
depending on what the user has inputted. The form goes to a
AddCompanyHandle.jsp page where the input is verified and added into
the database.

I have a different jsp page called Message.jsp which displays the
appropriate message in a separate frame. Thus, an example of which
message is to be displayed is shown below. (This code will be in
AddCompanyHandle.jsp)

Why make things so complex ?
<jsp:forward page="Message.jsp">
<jsp:param name="Msg" value="Please enter valid tel/fax number. Only
digits please" />
</jsp:forward>

Thus Message.jsp will run getParameter and display the message in a
separate frame called MessageFrame. (In order to do that, I already
set the target of the form to MessageFrame).

However, if the form is correctly filled and completed, I would like
to redirect the page to the main page. I used
response.sendRedirect("Main.jsp"). However due to the target which I
already set in the form, this page loads in the MessageFrame which is
not what I want. I want it to load in the MainFrame if and only if the
form is correctly filled.

So, my question is, is there a way where I can change the target of
the form after it is submitted and sens to a jsp page to be handled?

<form target="one" name="myform" onSubmit="

alert('Target is now: ' + document.myform.target);
document.myform.target = 'two';
alert('Target is now: ' + document.myform.target);

">
<input name="field">
<input type="submit">
</form>

Hope this helps,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,169
Latest member
ArturoOlne
Top