PDA

View Full Version : onchange submit


edbr
12-17-2007, 02:22 AM
In place of a submit button is it possible to have onchange submit? and if so how do I code submit?

davidj
12-17-2007, 06:04 AM
event
onchange="submitter()"

js function

function submitter(){

f = document.getElementById('form_id') //<< change form_id to your form id

f.submit();

}

you can also use IF conditionals in conjunction with f.action which can dynamically set the action of the form


function submitter(){

f = document.getElementById('form_id'); //<< change form_id to your form id

a = document.getElementById('field_value').value;

if (a==1){

f.action ="page1.php";

f.submit();

} else {

f.action ="page2.php";

f.submit();

}

}

edbr
12-17-2007, 06:57 AM
great, thank you. drove my self crazy trying to find how a submit button works!