Link to home
Start Free TrialLog in
Avatar of kulifaj
kulifaj

asked on

Cannot change form action - IE

Hi,
I have a very simple question. (just the answer is not easy for me :)

I'm using javascript function for submiting form to different pages, it looks like this:

<SCRIPT type="text/javascript">
    function dojob(myaction) {
        document.myform.action=myaction;
        document.myform.submit();
    }
</SCRIPT>

and form like this:

<FORM name=myform method=POST action="">
<INPUT type=button value="Assign" onclick="javascript:dojob('assign.php')">
</FORM>

and on Mozilla it works fine

but on Internet Explorer 5 or 6 it's not working, it shows javascript error that "Object doesn't support this property or method" and the error is made by "document.myform.action=myaction;" so it seems that IE doesn't support changing action of a form.

Is it true? Is there some other way how to change the action of a form in IE. Or am I missing something?
ASKER CERTIFIED SOLUTION
Avatar of justinbillig
justinbillig

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of sgalzin
sgalzin

hi,

i suspect you are calling the dojob function from another part in you script at a time the whole document is not yet loaded. could you please post the whole html page ?

thanks,

stephane.
Avatar of kulifaj

ASKER

As the script is generated by PHP and resulting script is rather long, it wouldn't be the best idea to paste the script here.
But as you posted the above, the script is really working, so the must be some other error in my script.

I was quite sure it was problem with IE, but I see now it's not. So I will have a look on my script and let you know.
paste the results of the generated PHP then please
errr ignore that
Avatar of kulifaj

ASKER

Hi, I got it.
Just a stupid name of one combobox (name=action) which replaced form method action with form control action.

Anyways thanks for your assistance, and as I don't know if it possible to give you only half of the points for assistance, I give you all 80.

Hi kulifaj,

  For future reference:  never assign a name that can be construed as a reserved word -- eg: name, form, action, etc.  -- to  a variable or field.  Browsers are just not that smart :)

Vinny