Solved

JQuery Keep div showing after refresh or form fail

Posted on 2014-01-28
5
920 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 to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Introduction JSON is an acronym for JavaScript Object Notation.  It is a text-string data transport mechanism, capable of representing simple or complex data structures in a consistent and easy-to-read manner.  Similar in concept to XML, but more e…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
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)
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…

758 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now