I think you should go the Javascript route, or at least I would
// 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();
});
});
من قبل
Feras Abualrub , Web Solutions Manager , Qistas for Information Technology
use jquery to submit a form by serializing all inputs you want to submit.
the below code is an ajax , for you take the first line which takes all input values located in a
function SubmitData()
{
var Data = $(".cs_slider").find('select').serialize() + '&'+ $(".cs_slider").find('input').serialize() + '&' + $(".cs_slider").find('textarea').serialize();
$.ajax({
url:'SubmitData.php',
data: Data,
type: 'POST',
success: function(rData)
{
alert(rData);
}
});
}
من قبل
Ankur Dadhich , Senior subject matter expert , Amdocs
Dude,
JQuery is the next thing that is used , the good old Javascript is gone out. for your question use this.... code..............
You need to refer the latest jquery library over this block to work.
$(function() {
Submitform();
});
functtion Submitform()
{
//Change #form to your form's ID
$('#form input').keydown(function(e) {
if (e.keyCode == 13) {
$('#form').submit();
}
});
}
من قبل
Furqan Ul Karim , Senior Delivery Manager (Contract) , Virgin Red
I have recently created a form on the run-time and got it submitted without a need to click on a submit button. Well this is not a magic just a normal javascript function i used for it. there are 2 ways you can do it either you code the form to submit on body load event e.g. see this below
Hope it will help
As Abdelhamid ABID pointed, a form with a button (submit or normal button) will submit on pressing Enter automatically without any JavaScript intervention. If you want to remove the button and make Enter the only submission method, just catch the event on the FORM element (the onkeypress event bubbles from children to the form itself):
$("form").on("keypress", function(e)
{
if(e.which == 13)
this.submit();
});
Try it on JSFiddle http://jsfiddle.net/ashraf_sabry_m/hYeTf/1/