I am trying to submit a form after the document is loaded. Why isn’t this piece of code not working?
[EDIT]: The page is resubmitting to itself
[EDIT]: I am running on Ubuntu 10.10 Firefox 3.6
<form id="myform" name="myform" action="chat.php" method="post">
<input type="hidden" name="displayname" id="displayname"/>
</form>
<script type="text/javascript">
$(document).ready(function (){
promptusername();
});
function promptusername()
{
$('#displayname').val(prompt("Enter your display name"));
//if($('#displayname').val() != null){
$('#myform').submit();
//}
//else{
//promptusername();
//}
}
</script>
I forgot the fact the page can be redirected from
chat.phpand so it was !!!