Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

JQuery Keep div showing after refresh or form fail

Posted on 2014-01-28
5
Medium Priority
?
984 Views
Last Modified: 2014-01-28
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?
0
Comment
Question by:rgranlund
  • 3
  • 2
5 Comments
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 39815997
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&
0
 
LVL 7

Author Comment

by:rgranlund
ID: 39816035
How can I do it with php and making the radio buttons sticky?
0
 
LVL 53

Accepted Solution

by:
COBOLdinosaur earned 2000 total points
ID: 39816053
When you go to the server save the values in the session, and then when you re-generate use the values in the session to generate the form, or pass the values as javascript variables, if you are generating the form with client side script.

Cd&
0
 
LVL 7

Author Comment

by:rgranlund
ID: 39816061
I'm to much of a newbie to completely understand that, but thank you anyway!
0
 
LVL 7

Author Comment

by:rgranlund
ID: 39816085
I will start the question over in a different way.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
In this blog, we’ll look at how improvements to Percona XtraDB Cluster improved IST performance.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

963 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question