history.back() problem with firefox

M

mohammed.naghman

Hi,

I have 2 submit buttons in a jsp page. One of them takes me to
page2.jsp and also passes the values enetered to page2.I have a link
in the page2 that does a history.back to come to the previous page to
make any chnages necessary. Now after making my changes, instead of
going to page2.jsp if I want to submit the page, Instead of submitting
the page it takes me to page2.jsp again.

This problem is only with firefox. It works fine with IE. Can anyone
help me on this?
 
S

shimmyshack

Hi,

I have 2 submit buttons in a jsp page. One of them takes me to
page2.jsp and also passes the values enetered to page2.I have a link
in the page2 that does a history.back to come to the previous page to
make any chnages necessary. Now after making my changes, instead of
going to page2.jsp if I want to submit the page, Instead of submitting
the page it takes me to page2.jsp again.

This problem is only with firefox. It works fine with IE. Can anyone
help me on this?

we'd love to help I am sure, but can only do so if you provide details
of the code and make sure you question makes a bit more sense!!
what are the two pages called, page2.jsp and page2.jsp and why do you
have 2 submit buttons on the page? and what does the other one do?
 
C

Christoph Burschka

Hi,

I have 2 submit buttons in a jsp page. One of them takes me to
page2.jsp and also passes the values enetered to page2.I have a link
in the page2 that does a history.back to come to the previous page to
make any chnages necessary. Now after making my changes, instead of
going to page2.jsp if I want to submit the page, Instead of submitting
the page it takes me to page2.jsp again.

This problem is only with firefox. It works fine with IE. Can anyone
help me on this?
I'll assume you made a typo and one of the pages mentioned is actually
called page1.jsp. Otherwise, this really doesn't make a lot of sense.

But without knowing where the typo is, it's practically impossible to
understand the question...

--cb
 
M

mohammed.naghman

I'll assume you made a typo and one of the pages mentioned is actually
called page1.jsp. Otherwise, this really doesn't make a lot of sense.

But without knowing where the typo is, it's practically impossible to
understand the question...

--cb

OK. Let me explain again.

I have Page1.jsp with 2 buttons. One button is used to navigate to
Page2.jsp and is a submit button. It submits the values enterd in
page1 to page2. This is done since some of the fields are common in
both pages and we do not want the user to re-enter the values if he
has already done so in page1.

The second button is again a submit button. But this one submits the
values of the fields entered in Page1.jsp and writes into the
database.

Now I use button1 and go to Page2.jsp, And I come back to page1.jsp
using a link that does a history.back(). I do this becoz I dont want
to enter anything in page2.jsp. So I come back to page1 and try to
submit the page using button2. Now instead of submitting the page and
writing to the databse, button2 behaves like button1 nad takes me to
page2.jsp again.

And this problem is only with firefox.
 
S

shimmyshack

OK. Let me explain again.

I have Page1.jsp with 2 buttons. One button is used to navigate to
Page2.jsp and is a submit button. It submits the values enterd in
page1 to page2. This is done since some of the fields are common in
both pages and we do not want the user to re-enter the values if he
has already done so in page1.

The second button is again a submit button. But this one submits the
values of the fields entered in Page1.jsp and writes into the
database.

Now I use button1 and go to Page2.jsp, And I come back to page1.jsp
using a link that does a history.back(). I do this becoz I dont want
to enter anything in page2.jsp. So I come back to page1 and try to
submit the page using button2. Now instead of submitting the page and
writing to the databse, button2 behaves like button1 nad takes me to
page2.jsp again.

And this problem is only with firefox.

I am assuming that you use javascript to changing the action of the
form in Page1.jsp to Page2.jsp when button1 is pressed, a change which
firefox preserves whereas IE "forgets".
Basically you want a single form with two buttons with different
names, one which said "submit this bit", and the other which is later
on that says "submit whole form" then the solution is to have both
buttons post back to Page1.jsp, if the submit button that was pressed
is button 1, then write out the form again (and add some js that jumps
them to the second section, and hey presto the user is back in the
page at the right place to carry on, if the second button is pressed
the great, let your server side logic show that. Having a dead page
isnt too good.
However if you do want to go that way have an onload statement that
initialises the form's action to whatever default you want it to be.
Personally I think having half a form submit is odd, if the data is
common to both things, then use a session to preserve state.
 
M

mohammed.naghman

I am assuming that you use javascript to changing the action of the
form in Page1.jsp to Page2.jsp when button1 is pressed, a change which
firefox preserves whereas IE "forgets".
Basically you want a single form with two buttons with different
names, one which said "submit this bit", and the other which is later
on that says "submit whole form" then the solution is to have both
buttons post back to Page1.jsp, if the submit button that was pressed
is button 1, then write out the form again (and add some js that jumps
them to the second section, and hey presto the user is back in the
page at the right place to carry on, if the second button is pressed
the great, let your server side logic show that. Having a dead page
isnt too good.
However if you do want to go that way have an onload statement that
initialises the form's action to whatever default you want it to be.
Personally I think having half a form submit is odd, if the data is
common to both things, then use a session to preserve state.- Hide quoted text -

- Show quoted text -

You are right. I am using javascript to change the action of the page
depending on which button is clicked.

I tried using the onload. This is how i used it

<body onload="setAction();">

and in setAction

function setAction()
{
document.formname.action = 'default action';
}

But it didnt work.

Is it the right way to use?
 
S

shimmyshack

You are right. I am using javascript to change the action of the page
depending on which button is clicked.

I tried using the onload. This is how i used it

<body onload="setAction();">

and in setAction

function setAction()
{
document.formname.action = 'default action';

}

But it didnt work.

Is it the right way to use?

well
document.getElementById('formID').action = 'Page1.jsp';
would work better, but you could also add a clause to the onsubmit of
the form, so that depending on which button is pressed it changes the
action to the required value.
Sorry I didnt say that before, thats the way I would probably do it,
given that I _had_ to do it this way :)
 
M

mohammed.naghman

well
document.getElementById('formID').action = 'Page1.jsp';
would work better, but you could also add a clause to the onsubmit of
the form, so that depending on which button is pressed it changes the
action to the required value.
Sorry I didnt say that before, thats the way I would probably do it,
given that I _had_ to do it this way :)- Hide quoted text -

- Show quoted text -

Thank you for the help provided. It works now with the above method. :)
 

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

Forum statistics

Threads
474,145
Messages
2,570,824
Members
47,371
Latest member
Brkaa

Latest Threads

Top