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?
LVL 4
kulifajAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
justinbilligConnect With a Mentor Commented:
<html>
<body>
<SCRIPT type="text/javascript">
    function dojob(myaction) {
        document.myform.action=myaction;
        document.myform.submit();
    }
</SCRIPT>
<FORM name=myform method=POST action="">
<INPUT type=button value="Assign" onclick="javascript:dojob('assign.php')">
</FORM>
</body>
</html>

that works fine ( well the page submits but it submits to nowhere cause i dont have assign.php on my computer )

what you might want to do is check and see what the value of myaction is



    function dojob(myaction) {
       alert( myaction );
        document.myform.action=myaction;
       alert( document.myform.action );
        //document.myform.submit();
    }
0
 
sgalzinCommented:
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.
0
 
kulifajAuthor Commented:
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.
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
justinbilligCommented:
paste the results of the generated PHP then please
0
 
justinbilligCommented:
errr ignore that
0
 
kulifajAuthor Commented:
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.

0
 
VincentPugliaCommented:
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
0
All Courses

From novice to tech pro — start learning today.