onclick事件使用javascript隐藏和显示2个表单

时间:2015-03-08 20:05:58

标签: javascript jquery html forms

我在单页中有两种形式,我想隐藏 class =“register”表单onclick “func(1)”并显示< b> class =“sign”表单,使用java脚本。
并onclick “func(2)”隐藏 class =“sign”表单并显示 class =“register”表格。

 <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>

1 个答案:

答案 0 :(得分:0)

尝试隐藏和显示,

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

}