Joann
Joann

Reputation: 1377

multiple form actions doesn't work using JS?

I have a form and then a JS function which processes it and does 3 actions. Here's my function:

function submit(){ 
    document.optin.action = "link1.php"
    document.optin.target = "_self"; 
    document.optin.submit();
    window.open('http://link2.html','','scrollbars=yes,height=600,width=900,resizable=yes');
    document.optin.action = "link3.php"
    document.optin.target = "_self"; 
    document.optin.submit();
}

The 2nd and 3rd actions work but the first does not. Actions 1 and 3 open on the same window with the latter overrides the former. Any idea what's wrong with my code? pls...

Upvotes: 1

Views: 198

Answers (1)

fmsf
fmsf

Reputation: 37147

The first one doesn't work because you're overriding the action with the 3rd one.

I don't know what you want to do, but you can't submit into two targets that are suposed to appear on the same window.

If the first submit is just for data purposes, I would sugest that you do the submit via ajax. so that the 3rd one doesn't overwrite the action.

Upvotes: 1

Related Questions