Visible form while click o n a link

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • robin1983
    New Member
    • Oct 2007
    • 99

    Visible form while click o n a link

    HI guys,
    I have a index.php page. This page contain two div. I m giving the code below:
    [HTML]
    <div id="v_div">
    You must login to access the pages <a href="#" onclick="visibl e_form()">Sign In</a>
    </div>
    <div id="form" style="visibili ty:hidden">
    <form name="login" method="post" action="login.p hp">
    <table width="50%" class="table1">
    <tr>
    <td align="left" class="td1">Use r Name:</td>
    <td align="left" class="td2">
    <input type="text" size="15" name="username" class="text" />
    </td>
    </tr>
    <tr>
    <td class="td1">Pas sword</td>
    <td class="td2">
    <input type="password" class="text" size="15" />
    </td>
    </tr>
    <tr>
    <td class="td1">Log in Type:</td>
    <td class="td2">
    <select name="logintype ">
    <option value="Admin">A dmin</option>
    <option value="User">Us er</option>
    <option value="Other">O ther</option>
    </select>
    </td>
    </tr>
    <tr>
    <td></td>
    <td class="td2"><in put type="button" value="login" />
    </tr>
    </table>
    </form>
    </div>
    [/HTML]

    now what i want is that when i click on the link Sign In, the below form should be visible. I try myself with the code given below
    [HTML]
    <script>
    function visible_form()
    {
    document.getEle mentById("form" ).innerHTML = visible;
    }
    </script>
    [/HTML]
    but unfortuantely its not working. plz help me .. thanks in advance
  • harshmaul
    Recognized Expert Contributor
    • Jul 2007
    • 490

    #2
    Hi mate...
    This should've been for the javascript forums, but next time yeah...

    but heres the markup fixed a little...

    you were using "innerhtml" this is what we use to change the content of an element....

    Code:
    <html>
    <head>
    <script>
    function visible_form()
    {
    document.getElementById("form").style.visibility = 'visible';
    }
    </script>
    
    </head>
    <body>
    <div id="v_div">
    You must login to access the pages <a href="#" onclick="visible_form()">Sign In</a>
    </div>
    <div id="form" style="visibility:hidden;">
    <form name="login" method="post" action="login.php">
                    <table width="50%" class="table1">
                        <tr>
                            <td align="left" class="td1">User Name:</td>
                            <td align="left" class="td2">
                                <input type="text" size="15" name="username" class="text" />
                            </td>
                        </tr>
                        <tr>
                            <td class="td1">Password</td>
                            <td class="td2">
                                <input type="password" class="text" size="15" />
                            </td>
                        </tr>
                        <tr>
                            <td class="td1">Login Type:</td>
                            <td class="td2">
                                <select name="logintype">
                                    <option value="Admin">Admin</option>
                                    <option value="User">User</option>
                                    <option value="Other">Other</option>
                                </select>
                            </td>
                        </tr>
                        <tr>
                            <td></td>
                            <td class="td2"><input type="button" value="login" />
                        </tr>
                    </table>                    
                </form>
    </div>
    </body>
    </html>

    Comment

    Working...