How to scroll down a page to view a div in a clicked link

On my html page there is a link for registration and a div that contains the registration form.

<a href="index.html"><img src="images/logo2.png" alt="LOGO"></a>


<div>
            <form method="POST" action="signup.php">
                <table>
                    <tr>
                        <td>First Name</td>
                        <td><input type="text" name="fname"></input></td>
                    </tr>
                    <tr>
                        <td>Last Name</td>
                        <td><input type="text" name="lname"></input></td>
                    </tr>
                    <tr>
                        <td>Email</td>
                        <td><input type="text" name="email"></input></td>
                    </tr>
                    <tr>
                        <td>Re-enter Email</td>
                        <td><input type="text" name="remail"></input></td>
                    </tr>
                    <tr>
                        <td>Password</td>
                        <td><input type="password" name="pwd"></input></td>
                    </tr>
                    <tr>
                        <td>Confirm Password</td>
                        <td><input type="text" name="cpwd"></input></td>
                    </tr>
                    <tr>
                        <td>Birthday</td>
                        <td><input type="text" name="bday"></input></td>
                    </tr>
                    <tr>
                        <td>Sex</td>
                        <td><input type="text" name="sex"></input></td>
                    </tr>
                    <tr>
                        <td><input type="submit" value="Signup"></input></td>
                        <td><input type="button" value="Cancel"></input></td>
                    </tr>
                </table>
            </form>
        </div>

I need to scroll down to the div when the user clicks on the registration link. Can someone explain how to do this. Thanx in advance ....

-1
source share
3 answers

To use only HTML, you can use the anchor tag.

<div><a id='form'></a>
  <form method="POST" action="signup.php">
  ...
</div>

Then your link will be as follows: <a href="#form">Click here to sign up</a>

Explanation: This link refers to an anchor tag awith idfrom form.

+2
source

Use the following

<a href="index.html"><img src="images/logo2.png" alt="LOGO"></a>
<a href="#test">Sign Up</a>


<div id="test">
            <form method="POST" action="signup.php"> ... </form>
</div>
+2
source

HTML, anchor, DivU.   "#" href . ,

<a href="#mySignUpDiv">Sign Up</a>


<div id="mySignUpDiv">
</div>
0

All Articles