Link to home
Start Free TrialLog in
Avatar of Robert Granlund
Robert GranlundFlag for United States of America

asked on

JQuery Keep div showing after refresh or form fail

I have a piece of JQuery code in a form that shows a specific div, if a radio button is clicked.
$(document).ready(function() {
[b]	$('input[type="radio"]').click(function() {
		if ($(this).attr("value") == "Create New Team") {
			$("#create_new_group").show('fast');
		}	[/b]	
	});

	$('input[type="select"]').checked(function() {
		if ($(this).attr("name") == "group_id") {
		$("#join_group").show('fast');
		}
	});

}); 

Open in new window


in that hidden div are additional form fields that contain a SELECT box.
$(document).ready(function() {
[b]	$('input[type="radio"]').click(function() {
		if ($(this).attr("value") == "Create New Team") {
			$("#create_new_group").show('fast');
		}	[/b]	
	});

	[b]$('input[type="select"]').checked(function() {
		if ($(this).attr("name") == "group_id") {
		$("#join_group").show('fast');
		}
	});[/b]

}); 

Open in new window


Right now if the form is submitted and fails or if the page refreshes, the initial div is closed.  The second piece of code is meant to keep open the initial div upon refresh or form fail, cause the form select choices are sticky.  BUT it does not work.

Any help?  Does this question make sense?
Avatar of COBOLdinosaur
COBOLdinosaur
Flag of Canada image

The browser does not maintain state betwen pages.  A refresh and submit, both go to the server and anything that must be retained has to be done on the server side in session. if you want the browser to  "remember", then you need to save those memories in cookies (some users may not accept them) and then retrieve them on page load.

Cd&
Avatar of Robert Granlund

ASKER

How can I do it with php and making the radio buttons sticky?
ASKER CERTIFIED SOLUTION
Avatar of COBOLdinosaur
COBOLdinosaur
Flag of Canada 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
I'm to much of a newbie to completely understand that, but thank you anyway!
I will start the question over in a different way.