So I have a javascript function that validaes a form and then submits it. The code is something like this: var f = document.myform; if(f){ f.action = 'test.php'; f.method='post'; f.submit(); } this code works for all browsers except IE6. does anyone know of a workaround? I need to use javascript submit because I don't want the form to submit when the user presess "enter".
What's the line failing in IE6? In the mean time, you can try: var f = document.getElementById('myform'); if (f) { f.action = 'test.php'; f.method = 'post'; f.submit(); } Code (markup): Be sure your form tag has id attribute: <form action="" name="..." id="myform" .... Code (markup):
document.getElementById() is a standard function and work for most navigators out there. Using other syntax, like you proposed is error prone.