I am new to JavaScript & php.
How can one submit a form without using submit button?
if possible without using anchor tag.
Please guide me how to achieve this task.
I am new to JavaScript & php.
How can one submit a form without using submit button?
if possible without using anchor tag.
Please guide me how to achieve this task.
just use following code
<form id="jsform" action="whatever you want">
// input fields
</form>
<script type="text/javascript">
document.getElementById('jsform').submit();
</script>
you can submit it with the use of javascript submit()
function
<script type="text/javascript">
function submitform()
{
document.forms["myform"].submit();
alert("Value is sumitted");
}
</script>
<form id="myform" action="submit.php" method="post">
Search: <input type="text" name="query">
<a href="javascript: submitform()">Submit</a>
</form>
I think you can make your submit button's visibility 'hidden' and use the following javascript.
<script type="text/javascript">
// Using jQuery.
$(function() {
$('form').each(function() {
$('input').keypress(function(e) {
// Enter pressed?
if(e.which == 10 || e.which == 13) {
this.form.submit();
}
});
$('input[type=submit]').hide();
});
});
</script>
<form name="formName" method="post">
<input name="someName" type="text" /><br />
<input name="somePass" type="password" />
<input type="submit" style="visibility: hidden;" />
</form>
In javascript it must use the form submit() method implemented in a custom button or anchor.
In PHP you can use the curl library (client URL library).