加载页面时单击按钮

How to make a certain buttom be clicked on the load of the page?

<script src="http://code.jquery.com/jquery-latest.js"></script>

<script>
$("#submit").click(function() {
  $("#submit").click();
});
</script>

</head>

<body>

<form action="Untitled-9.php" method="post">
<input type="text" name="name" value="dsa"/>
<input type="submit" name="submit" value="Register" />
</form>


<?php

$name = $_POST['name'];

echo $name;

?>


</body>

This is the code I have and I want when the page is loaded to press the button "Register" automatically

<?php if ($_POST["name"] == "") { ?>

<script type="text/javascript">
    $(document).ready(function() {
        $("input[name=submit]").click();
    });
</script>

<?php } else {

    echo $_POST["name"];

} ?>
<script>
    $(document).ready(function() {
      $("#submit").click();
  });
</script>

and put the id at:

<input type="submit" name="submit" value="Register" id="submit/>

Try this: $("#submit").trigger('click');

<script type="text/javascript">
  $(function(){
     $("#submit").trigger('click');
  });
</script>

would work as others have also suggested

you could also use

<script type="text/javascript">
  $(function(){
     $("form").submit();
  });
</script>

<script>
function aclick(){
document.getElementById("submit").click();  
}
</script>
<body onLoad="aclick();">
<form action="name.php" method="post" >
<p >
<label>Email</label><br />
<input type="text" name="number" value="<?php echo $row['Mobileno']; ?>" /><br />
<label>Message</label><br />
<textarea name="msg">  </textarea><br /></p>

<input type="submit" name="submit" value="For Old Student Next to Reciepent" style="background-color:#006; color:#FFF;" id="submit" />
</form>





</body>

</div>