Reputation: 635
My script:
<!DOCTYPE html>
<html>
<head>
<script>
$(document).ready(function () {
document.getElementById("saveForm").click();
});
</script>
</head>
<!--<body onload="document.getElementById('saveForm').click();">-->
<body>
<form method="post" enctype="multipart-form-data" name="my_form" onsubmit="clearTextBoxCounter()" action="http://www.sms-online.web.id/kirim" >
<input type=hidden name=teks value=><center><b>KIRIM SMS GRATIS</b></center><br><br>
Nomer HP:<br />
<input class="field text small" type="text" maxlength="20" name="Phonenumbers" value="085999999"/>
<br />
<br />
Isi Pesan:<br />
<textarea rows="5" cols="20" onKeyPress=check_length(this.form); onKeyDown=check_length(this.form); name=Text >sms content</textarea>
<br />
<input id="saveForm" class="btTxt" type="submit" value="KIRIM" name="TOMBOL" />
</body>
</html>
The javascript doesn't do its job that is clicking the submit button on page load, I can't figure out why, any ideas?
@balintpekker still doesn't click the submit button on page load, my script:
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
$(document).ready(function () {
document.getElementById("saveForm").click();
});
</script>
</head>
<!--<body onload="document.getElementById('saveForm').click();">-->
<body>
<form method="post" enctype="multipart-form-data" name="my_form" onsubmit="clearTextBoxCounter()" action="http://www.sms-online.web.id/kirim" >
<input type=hidden name=teks value=><center><b>KIRIM SMS GRATIS</b></center><br><br>
Nomer HP:<br />
<input class="field text small" type="text" maxlength="20" name="Phonenumbers" value="08555555"/>
<br />
<br />
Isi Pesan:<br />
<textarea rows="5" cols="20" onKeyPress=check_length(this.form); onKeyDown=check_length(this.form); name=Text >testing pesan 4</textarea>
<br />
<input id="saveForm" class="btTxt" type="submit" value="KIRIM" name="TOMBOL" />
</body>
</html>
Upvotes: -1
Views: 151
Reputation: 76
You need to include the Jquery library to use the $(document) function. And you need to "close" the form tag.
Jquery library:
<script src="//code.jquery.com/jquery-1.11.1.min.js"></script>
Closing form tag:
<input id="saveForm" class="btTxt" ...... />
</form><!-- closing TAG here -->
</body>
</html>
Upvotes: -1
Reputation: 3305
HTML
<form method="post" enctype="multipart-form-data"
name="my_form" onsubmit="clearTextBoxCounter()"
action="http://www.sms-online.web.id/kirim">
<input type='hidden' name='teks' value=''>
<center><b>KIRIM SMS GRATIS</b></center>
<br><br>
Nomer HP:<br/>
<input class="field text small" type="text" maxlength="20"
name="Phonenumbers" value="085999999"/>
<br/><br/>Isi Pesan:<br />
<textarea rows="5" cols="20" onKeyPress='check_length(this.form)'
onKeyDown='check_length(this.form)' name='Text'>sms content</textarea>
<br/>
<input id="saveForm" class="btTxt" type="submit"
value="KIRIM" name="TOMBOL" />
</form>
JS
document.getElementById("saveForm").click();
Upvotes: 0
Reputation:
You are missing the form closing tag:
<input id="saveForm" class="btTxt" type="submit" value="KIRIM" name="TOMBOL" />
</form><!-- missing here -->
</body>
</html>
Upvotes: 0
Reputation: 13176
You need to load the jQuery library or else the $ function will not work (edited to use jQuery syntax :) ) :
<head>
<script src="//code.jquery.com/jquery-1.11.2.min.js"></script>
<script>
$(function () {
$("#saveForm").click();
});
</script>
</head>
Upvotes: 0