Solved

JQuery Keep div showing after refresh or form fail

Posted on 2014-01-28
5
947 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 500 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

How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

Question has a verified solution.

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

Suggested Solutions

In this article you'll learn how to use Ajax calls within your CodeIgniter application. To explain this, I'll illustrate how to implement a simple contact form to allow visitors to send you an email through your web site.
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 …
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. 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.: (CODE)

763 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