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

asked on

PHP Sticky For to pass variable to JQuery

I want to pass a php form sticky entry to Jquery upon page refresh.

PHP Code:
	function choose_registration_type() {
		echo '  <h4>I Would Like To:</h4><br />
				<input type="radio" name="team_join" id="create_new_team" value="Create New Team" />Create New Team<br />
				<input type="radio" name="team_join" id="join_existing_team" value="Join Existing Team"'; if(isset($_POST['team_join']) && $_POST['team_join'] == "Join Existing Team") {echo'checked';} echo'/>Join Existing Team<br />
				<input type="radio" name="team_join" id="join_individually" value="Join Individually" />Join Individually';
	}

Open in new window

So if the form fails, the radio button is still chosen. However, this is within a div that is shown/hidden by JQuery  with a $(document).ready(function()

So since this radio button is already "Checked" I want the div to automatically show.
But, the following does not work:
$(document).ready(function() {
$('input[type="radio"]').checked(function() {
		if ($(this).attr("value") == "Join Existing Team") {
		$("#join_group").show('fast');
		}
	});
});

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of leakim971
leakim971
Flag of Guadeloupe 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
...if the form fails, the radio button is still chosen
What do you mean by if the form fails?
Avatar of Robert Granlund

ASKER

This was exactly what I needed.  I'm slowly learning JQuery and this helped!