Solved

Cannot change form action - IE

Posted on 2004-09-07
7
855 Views
Last Modified: 2008-02-01
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?
0
Comment
Question by:kulifaj
7 Comments
 
LVL 15

Accepted Solution

by:
justinbillig earned 80 total points
ID: 11995476
<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
 
LVL 4

Expert Comment

by:sgalzin
ID: 11995674
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
 
LVL 4

Author Comment

by:kulifaj
ID: 11995932
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 15

Expert Comment

by:justinbillig
ID: 11996214
paste the results of the generated PHP then please
0
 
LVL 15

Expert Comment

by:justinbillig
ID: 11996219
errr ignore that
0
 
LVL 4

Author Comment

by:kulifaj
ID: 11996503
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
 
LVL 15

Expert Comment

by:VincentPuglia
ID: 11996545
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

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now