Click to See Complete Forum and Search --> : Changing form action in IE


bede
02-26-2003, 07:27 PM
I've got a form with two submit buttons and if one of them is clicked it should change the action of the form. For some stupid reason the code below isn't working.

<input type="submit" name="send" value="send"
onClick="javascript: document.forms[0].action='sender.php'">

IE complains that there is no such property or method called action for the form object. If i put "forms[0].ACTION=...." it dowsn't give an error but doesn't change the action at all. I've read that IE didn't support the changing of action in IE v3 put i'm using v6. Please help!!

Jona
02-26-2003, 08:03 PM
Try using two forms

bede
02-26-2003, 08:07 PM
I'd rather not. I'm posting the same elemetns to both scripts so its definately the easiest thing to do. I don't want a work around, there should be a simple explanation for it.

Jona
02-26-2003, 08:27 PM
DO'H! I was thinking something else... Yeah, hehe, I getcha. Sorry, I don't really know.

bede
02-26-2003, 09:36 PM
no luck. Still "object does not support this property or method". I've checked my code many times over and everything seems to be fine. It doesn't complain when I change the method, enctype or any other property. And why doesn't it complain when I put a property name in uppercase? I can even put "this.form.HJKHKJ='blah'" and it doesn't give me an error. Did I mention I hate Javascript & DOM?

Nedals
02-26-2003, 09:44 PM
<input type="submit" name="send" value="send"
onClick="java script: document.forms[0].action='sender.php'">
If this is a direct paste of your code, the problem is simply that 'javascript' in one word although you don't need it at all.

<input type="submit" name="send" value="send"
onClick="document.forms[0].action='sender.php'">

should work.

bede
02-26-2003, 09:49 PM
OK, I'm an idiot. I had a hidden field called "action" which it was obviously getting confused with. I just thought it would have only assumed I was referencing the hidden field if I'd tried to access one of its properties.

(eg document.forms[0].action.value='blah')