Feedback on: irt.org FAQ Knowledge Base Q682
Worth:
Very worth reading
Comments:
This works fine, but how can I do it with 3 input fields?
Worth:
Length:
Technical:
Comments:
//put this code any where between your <head> tags.
function addInputSubmitEvent(form, input) {
input.onkeydown = function(e) {
e = e || window.event;
if (e.keyCode == 13) {
form.submit();
return false;
}
};
}
window.onload = function() {
var forms = document.getElementsByTagName('form');
for (var i=0;i < forms.length;i++) {
var inputs = forms[i].getElementsByTagName('input');
var selects = forms[i].getElementsByTagName('select');
for (var j=0;j < inputs.length;j++)
addInputSubmitEvent(forms[i], inputs[j]);
for (var j=0;j < selects.length;j++)
addInputSubmitEvent(forms[i], selects[j]);
}
};
//<!-- Taken from: http://www.thefutureoftheweb.com/blog/submit-a-form-in-ie-with-enter
and improved a bit by http://useful.2ya.com -->
Worth:
Length:
Technical:
Comments:
//put this code any where between your <head> tags.
function addInputSubmitEvent(form, input) {
input.onkeydown = function(e) {
e = e || window.event;
if (e.keyCode == 13) {
form.submit();
return false;
}
};
}
window.onload = function() {
var forms = document.getElementsByTagName('form');
for (var i=0;i < forms.length;i++) {
var inputs = forms[i].getElementsByTagName('input');
var selects = forms[i].getElementsByTagName('select');
for (var j=0;j < inputs.length;j++)
addInputSubmitEvent(forms[i], inputs[j]);
for (var j=0;j < selects.length;j++)
addInputSubmitEvent(forms[i], selects[j]);
}
};
//<!-- Taken from: http://www.thefutureoftheweb.com/blog/submit-a-form-in-ie-with-enter
and improved a bit by http://useful.2ya.com -->