Link to home
Start Free TrialLog in
Avatar of kiwistag
kiwistagFlag for New Zealand

asked on

Backwards behaviour with html

I have a site that uses cookies and also has 2x radio buttons,  the Radio buttons when either are selected cause the Submit button on the form to enable to inhibit the choice being missed.
onClick="document.getElementById('next').disabled = false"

Open in new window


On the next screen it confirms the details and if need be offers the option to go back
onclick="history.back()"

Open in new window

.
Unfortunately, the Submit button is re-set to disable, even though the Radio button is already selected.

The other issue is that sometimes when going backwards then re-submitting, some of the changes aren't carried over, if you go back and hit submit again however it's fine. My testing on this issue initially showed it was just a timing thing.

At present the biggest issue is the onback function and avoiding disabling the Submit/Next button.

If anyone can help with either or both it'd be much appreciated.
ASKER CERTIFIED SOLUTION
Avatar of Justin Pilditch
Justin Pilditch
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of kiwistag

ASKER

Thanks, that worked perfectly.
As for the cookie issue, I've tried suggestions as from here, but it's inconsistent.
You didn't mention what the cookies were doing but assuming it is related I imagine any problem is the same case as the submit button in that when you go back the page is not processed as a fresh load (or a reload) so the php doesn't parse and you cookie control does not run.

So the solution could be the same, in that you use the body onload to call functions that do the necessary - you could look at using a jQuery cookie manager like this one:

https://github.com/carhartl/jquery-cookie
Looks like the step-backwards doesn't behave the same in Chrome.
In fact even the Cookies don't behave the same in Chrome, but apparently this is common..

New coding/change of the cookies has made it so the first time has a higher chance of working the first time (sometimes not in Chrome), however when going back in Firefox, the fields are cleared but are holding in Chrome.
I've requested that this question be deleted for the following reason:

The question has either no comments or not enough useful information to be called an "answer".
I beg to differ - I appreciate that the author threw back a subsequent problem but in terms of the original question and my original answer I think the author's response of "Thanks, that worked perfectly." would suggest that my answer is quite something more than "not enough useful information to be called an answer" and worthy of some points.