how do you open a div based on url parameter

Hi

I have some div's that need to be open and closed based on a url parameter.

Is that possible.

Here is my code so far:

<script type="text/javascript">
jQuery(document).ready(function() {
  jQuery(".menu_Specialties").show();
  //toggle the componenet with class msg_body
  jQuery(".heading1").click(function()
  {
    jQuery(this).next(".menu_Specialties").slideToggle(500);
  });
});
</script>

Open in new window

Is there a way to take :  jQuery(".menu_Specialties").show(); and wrap it in a conditional statement?

Thanks!
smfmetro10Asked:
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.

plusone3055Commented:
if url parameter = x 
jQuery(".menu_Specialties").show();
else 
//do nothing 
end if

Open in new window

0
smfmetro10Author Commented:
Thanks for the reply!

On one of sections there will be "specialty" as a parameter.

is this close?

<script type="text/javascript">
jQuery(document).ready(function() {
if url parameter = "specialty" 
jQuery(".menu_Specialties").show();
else
jQuery(".menu_Specialties").hide();
end if 
  //toggle the componenet with class msg_body
  jQuery(".heading1").click(function()
  {
    jQuery(this).next(".menu_Specialties").slideToggle(500);
  });
});
</script>

Open in new window

0
plusone3055Commented:
<script type="text/javascript">
jQuery(document).ready(function() {
if url parameter = "specialty" 
jQuery(".menu_Specialties").show();
//toggle the componenet with class msg_body
  jQuery(".heading1").click(function()
  {
    jQuery(this).next(".menu_Specialties").slideToggle(500);
  });

else
jQuery(".menu_Specialties").hide();
end if 
  });
</script>

Open in new window

0
smfmetro10Author Commented:
I know this is a newbie question but Dreamweaver thinks there is a syntax error with this line:

if url parameter = "specialty"
0
RobOwner (Aidellio)Commented:
url parameter was a pseudo for an actual variable.  in reality there would be no space.

You can use this function to get a parameter value from the querystring:

function getParameterByName(name) {
    name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
    var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
        results = regex.exec(location.search);
    return results == null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
}

Open in new window


and slightly modifying @plusone3055's code:

<script type="text/javascript">
jQuery(document).ready(function() {
if (getParameterByName("specialty") !== null) { 
jQuery(".menu_Specialties").show();
//toggle the componenet with class msg_body
  jQuery(".heading1").click(function()
  {
    jQuery(this).next(".menu_Specialties").slideToggle(500);
  });

else {
    jQuery(".menu_Specialties").hide();
} 
  });
</script>

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.