How can I advance to this page and THEN adjust visibility?

Here's my Javascript function:

function Florida()
{
$(".Louisiana,.Mississippi,.Tennessee").hide();
$(".Florida").show();
return false;
}

I need to advance the user to a different page with this function and then manipulate the divs as far as what's hidden and what's not. How would I do that?

In other words, I need:

function Florida()
{
//advance to index.php?month=9&year=2015 the...
//hide and / show the various divs
$(".Louisiana,.Mississippi,.Tennessee").hide();
$(".Florida").show();
return false;
}

How could I pull that off?
brucegustPHP DeveloperAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

hieloCommented:
First of all, instead of having one function per state, a better option is to have one function that hides all the states, except the one specified.  So instead of:
<div class="Louisiana" style="display: inline;">...</div>
<div class="Mississippi" style="display: inline;">...</div>

Open in new window


Use:
<div class="US-State Louisiana" style="display: inline;">...</div>
<div class="US-State Mississippi" style="display: inline;">...</div>

Open in new window


Then use:
// the following function replaces "function Florida(){...} function Mississippi(){...}", etc.
// you just need to call showState('Florida'); and it will hide all the state "cells" except Florida
function showState(str){
   $(".US-State").hide();//hides all the calendar "cells" with class="US-State"
   $("." + str).show();//shows only the cells that match the name specified in str
}

Open in new window


As for navigating away from the page and hiding the adequate cells upon load, instead of using this markup:
<a href="#" class="table_states" onclick="return Florida();"><b>Florida</b></a>

Open in new window


Use:
<a href="index.php?month=9&year=2015&state=Florida" class="table_states"><b>Florida</b></a>

Open in new window


Then, on the backend, check for "$_GET['state']".  If it exists, then upon load, call the function to hide all the states, except the one specified.
<?php
//whatever you are doing here
?>
<html>
<head>
<link href="stylesheet.css" rel="stylesheet" type="text/css" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.js" type="text/javascript"></script>
<script type="text/javascript">
 $(document).ready(function(){
 
		$(".slidingDivTerms").hide();
		$(".show_hide").show();
 
	$('.show_hide').click(function(){
	$(this).next().slideToggle();
	});
	
});
 </script>
<?php
  if( array_key_exists('state',$_GET) && preg_match('/^[a-z]+$/i', $_GET['state']) )
  {
    echo "
     <script type='text/javascript'>
    $(document).ready(function(){
         show('{$_GET['state']}');
     });
     </script>
    ";
  }
?>
</head>
<body>
<a href="index.php?month=9&year=2015&state=Florida" class="table_states"><b>Florida</b></a>
</body>
</html>

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.