2015-03-08 75 views
0

我有在單個頁面兩種形式,
我想隱藏類2所形成=「寄存器」形式的onclick 「FUNC(1)」並顯示類=「號「窗體,使用java腳本。
and onclick 「func(2)」 hide class =「sign」 form and shows class =「register」 form。onclick事件隱藏和顯示使用javascript

<form method="post" action="agent.php" id="register_form" class="register" style="display:block;" name="form1" >      
       <h2>Sign-up </h2> 
       <input type="text" id="name" name="agent_name" placeholder="Agent Name.."/> 
       <input type="text" id="mail" name="agent_email" placeholder="E-Mail.." /> 
       <input type="text" id="password" name="agent_password" placeholder="Password.." /> 
       <input type="text" id="number" name="agent_mobile" placeholder="Mobile...." /> 
       <br><br><br><br><br><br><br><br><br> 


        <select class="form-control sele" name="agent_state" id="country" for="u_state" style="background: rgb(235,235,235);" onChange="getCity('findcity.php?country='+this.value)"> 
         <option value="" selected class="below">Choose state from below...</option> 
          <?php 
           while($row = mysql_fetch_array($result)) 
           { 
            $State = $row['state']; 
            $StateID = $row['state_id'];           
            echo "<option value=". $StateID ." cna=".$State.">" . $State ."</option>"; 
           } 
          ?> 
        </select> 

       <br> 
       <div id="citydiv"> 
        <select class="form-control sele" name="agent_location" for="u_city" style="background: rgb(235,235,235);"> 
         <option value="" selected class="below">Choose Location from below...</option> 
        </select> 
       </div> 


       <!-- Agree with the term of services --> 
       <input type="checkbox" id="tos" name="tos" /> 
       <label for="tos">Accept the <a href="">Terms of service</a></label> 
       <!--<input type="checkbox" id="news" name="news"> 
       <label for="news">Subscribe to our newsltetter !</label>--> 

       <!-- // // // // // // // // // // -->      
       <input type="submit" id="" name="reg_agent" value="Register" /> 
       <input type="submit" id="sign2" value="Already A Member ? Sign_In" onclick="func(1)"/> 

       </form> 


     <!--//////// AGENT SIGN IN FORM ///////////--> 


      <div> 
       <form method="post" action="#" id="signin_form" class="sign" style="display:none;" name="form1" id=""> 
       <h2>Sign-In </h2> 
       <input type="text" id="name" name="name" placeholder="Agent Name/E-Mail_Id"/> 
       <input type="text" id="password" name="password" placeholder="Password.." /> 
       <!-- Agree with the term of services --> 
       <input type="checkbox" id="tos" name="tos" /> 
       <label for="tos">Remember Me</label> 
       <!--<input type="checkbox" id="news" name="news"> 
       <label for="news">Subscribe to our newsltetter !</label>--> 

       <!-- // // // // // // // // // // -->  
       <input type="submit" id="" value="Sign_In" onclick="window.location.href = 'agent_profile.php' " /> 
       <input type="submit" id="register2" value="Not A Member.... Register" onclick="func(2)"/> 

       <div> 
        <br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br> 
       </div> 
       </form> 
      </div> 

回答

0

嘗試隱藏和顯示,

function func(para) 
{ 
if(para==1) 
{ 
$(".sign").show(); 
$(".register").hide(); 
} 
else if(para==2) 
{ 
$(".sign").hide(); 
$(".register").show(); 
} 

} 
+0

不工作毗溼奴。 onclick func(1)頁面正在重新加載 – 2015-03-08 20:23:49

+0

把輸入按鈕拿出 – Vishnu 2015-03-08 20:46:08

+0

謝謝毗溼奴,它的工作原理。 – 2015-03-09 04:01:37