javascript - Hiding a DIV on return of if/else statement -


i've been trying hide div id #signup within code i'm working in , can't seem work i've been doing. way of hiding div id fading out , in return fading in new div #test? here's got!

html (index)

     <form id="signup" action="<?=$_server['php_self']; ?>" method="get">       <fieldset>            <label for="email" id="address-label">email address</label>           <input type="text" name="email" id="email" />           <input type="image" src="i/join.jpg" name="submit" value="join" class="btn" alt="join" />        </fieldset>     </form>      <div id="response">         <? require_once('inc/store-address.php'); if($_get['submit']){ echo storeaddress(); } ?>         <div id="test">test</div>     </div> 

css

#test {display: none;} 

js/php (inc/store-address.php)

<?php function storeaddress(){      if($api->listsubscribe($list_id, $_get['email'], '') === true) {         // worked!     ( "#signup" ).hide( "slow" );        ( "#test" ).show( "slow" );     }      else {         // error ocurred, return error message            return 'error: ' . $api->errormessage;     }  }  // if being called via ajax, autorun function if($_get['ajax']){ echo storeaddress(); } ?> 

from can see trying mix php , javascript in 1 function, not work. php runs serverside before webpage has been sent client, , javascript runs on client , after page has been sent.

you need in javascript likely, jquery light library highly reccomended task this.

here link code below harvested from.

$("#hide").click(function(){   $("p").hide(); });  $("#show").click(function(){   $("p").show(); }); 

Comments

Popular posts from this blog

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -

php - Magento - Deleted Base url key -

android - How to disable Button if EditText is empty ? -