1

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...

1
  • the action you don't see is a get request on a new window :) Commented Apr 19, 2010 at 11:02

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

2 Comments

Changing the target of the 1st to _blank does not work either. :( The idea is, the 1st action does the submission of the data to the server so nothing should be displayed about it. While the 3rd displays the page of the next phase of the process. You know what? This code was working until recently. I don't know what went wrong.. :(
what's going wrong is that you're trying to submit twice and the second submition overwrites the first. If that's really it, then just use ajax for the first submission, it will simplify your life :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.