tags:

views:

55

answers:

4
url 1 = www.xyz.co.uk/asd.qmd
url 2 = www.xyz.co.uk/asd.qmd?getstep=4#

I want to show a div(left) when PAGE URL is www.xyz.co.uk/asd.qmd?getstep=4#

IN PAGE form.php I write THE CODE

<script language="text/javascript">
 $(function(){
     var locate = window.location;

      if (locate=="http://localhost/school/form.php") {
  $('#left').hide();
} else {
  $('#left').show();
       }
    });

       </script>




 <body  onload="function()">
<div id="left">
  aasdsasdfdsgfg
      </div>

    </body>

but this is not working

A: 

You need to make a show/hide function the proper javascript way. What you are doing at first with the (I assume) jQuery is beyond me - just declare a simple function containing the code you already have to show/hide and attach it to the onload-event.

mbanzon
+2  A: 

Just make php condition

<?php
if($_GET['getstep']){

}
?>
jatt
A: 

If you just want to hide the div when the query string is empty, you could use the search property of the window.location object:

$(function(){
      if (window.location.search === "") {
            $('#left').hide();
      } else {
            $('#left').show();
      }
 });

Anything more complicated (i.e. a different div for each page value) and I recommend you look at regex

Jonathon
A: 

You need to use the href proprerty of window.location object.

var locate = window.location.href,
myElement = $('#left');
locate == "http://localhost/school/form.php" ? myElement.show() : myElement.hide();

Luca