Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #18750 > unrolled thread

How to submit a form with two actions?

Started byjustaguy <lichunshen84@gmail.com>
First post2013-03-07 13:18 -0800
Last post2013-03-08 20:50 +0100
Articles 20 — 7 participants

Back to article view | Back to comp.lang.javascript


Contents

  How to submit a form with two actions? justaguy <lichunshen84@gmail.com> - 2013-03-07 13:18 -0800
    Re: How to submit a form with two actions? Danny <dann90038@gmail.com> - 2013-03-07 14:40 -0800
      Re: How to submit a form with two actions? justaguy <lichunshen84@gmail.com> - 2013-03-07 14:46 -0800
        Re: How to submit a form with two actions? Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2013-03-07 15:31 -0800
          Re: How to submit a form with two actions? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2013-03-08 00:42 +0100
            Re: How to submit a form with two actions? Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2013-03-07 15:55 -0800
              Re: How to submit a form with two actions? justaguy <lichunshen84@gmail.com> - 2013-03-07 16:43 -0800
                Re: How to submit a form with two actions? Stefan Weiss <krewecherl@gmail.com> - 2013-03-08 02:55 +0100
                  Re: How to submit a form with two actions? justaguy <lichunshen84@gmail.com> - 2013-03-07 18:09 -0800
                    Re: How to submit a form with two actions? Stefan Weiss <krewecherl@gmail.com> - 2013-03-08 04:21 +0100
                      Re: How to submit a form with two actions? justaguy <lichunshen84@gmail.com> - 2013-03-07 19:37 -0800
                        Re: How to submit a form with two actions? Stefan Weiss <krewecherl@gmail.com> - 2013-03-08 13:18 +0100
      Re: How to submit a form with two actions? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-03-08 20:51 +0100
    Re: How to submit a form with two actions? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2013-03-07 23:52 +0100
    Re: How to submit a form with two actions? justaguy <lichunshen84@gmail.com> - 2013-03-07 15:16 -0800
      Re: How to submit a form with two actions? Danny <dann90038@gmail.com> - 2013-03-07 15:22 -0800
      Re: How to submit a form with two actions? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2013-03-08 00:37 +0100
        Re: How to submit a form with two actions? justaguy <lichunshen84@gmail.com> - 2013-03-07 16:44 -0800
      Re: How to submit a form with two actions? Denis McMahon <denismfmcmahon@gmail.com> - 2013-03-09 05:09 +0000
    Re: How to submit a form with two actions? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-03-08 20:50 +0100

#18750 — How to submit a form with two actions?

Fromjustaguy <lichunshen84@gmail.com>
Date2013-03-07 13:18 -0800
SubjectHow to submit a form with two actions?
Message-ID<d7794c16-2790-4efb-b512-fba93780e624@googlegroups.com>
Is it possible?  If so, the following script does not work, what's wrong?  Thanks.

<script type="text/javascript">
	
	function doubleSubmit(f)
		{
		  // submit to action in form
		  f.submit();
		  // return false;
		  
		  // set second action and submit
		  // f.target="_blank";
		  f.action="action2.html";		  
		  f.submit();
		  // return false;
		}

</script>

<form name="checkout" method="post" action="action1.html" onsubmit="doubleSubmit(this)">
	<input type="text" name="customer">
	<input type="hidden" name="dev" value="test">
	<input type="submit" name="send" value="Place Order">
</form>

[toc] | [next] | [standalone]


#18752

FromDanny <dann90038@gmail.com>
Date2013-03-07 14:40 -0800
Message-ID<4cd82dec-4808-42b8-8a8a-3ff6568bf25c@googlegroups.com>
In reply to#18750
To justaguy

usually, you don't need to submit a form twice, you have the script on the server handle the double processing on 1 submit from the client only.  That said, what's action1.html and action2.html supposed to do?

[toc] | [prev] | [next] | [standalone]


#18753

Fromjustaguy <lichunshen84@gmail.com>
Date2013-03-07 14:46 -0800
Message-ID<0da7e141-5cec-4509-a733-b50a01aae916@googlegroups.com>
In reply to#18752
It's not a usual case.

Action1 is for an existing business rule, that is, process orders.  Where we don't have access to the database.

Action2 is is a new business need, that is, send the form data to a new URL, that would capture the order info in a central database.

Do you know an answer to the code posted?


>On Thursday, March 7, 2013 5:40:41 PM UTC-5, Danny wrote:
> To justaguy
> 
> 
> 
> usually, you don't need to submit a form twice, you have the script on the server handle the double processing on 1 submit from the client only.  That said, what's action1.html and action2.html supposed to do?

[toc] | [prev] | [next] | [standalone]


#18760

FromDaniel Pitts <newsgroup.nospam@virtualinfinity.net>
Date2013-03-07 15:31 -0800
Message-ID<hr9_s.6798$sI3.365@newsfe22.iad>
In reply to#18753
On 3/7/13 2:46 PM, justaguy wrote:
> It's not a usual case.
>
> Action1 is for an existing business rule, that is, process orders.  Where we don't have access to the database.
>
> Action2 is is a new business need, that is, send the form data to a new URL, that would capture the order info in a central database.
>
> Do you know an answer to the code posted?
>
>
>> On Thursday, March 7, 2013 5:40:41 PM UTC-5, Danny wrote:
>> To justaguy
>>
>>
>>
>> usually, you don't need to submit a form twice, you have the script on the server handle the double processing on 1 submit from the client only.  That said, what's action1.html and action2.html supposed to do?
>
This is an extremely dangerous approach. The reason being that the 
client may fail halfway through, and you end up with inconsistent data. 
  It is much better to fix the server side of things.  "New Business 
Need" does not mean "New URL".

Worst case scenario, have the "new" url server-side code push the form 
to the old URL.  Don't rely on the client to do that.  Always assume 
that the client is going to do everything it can to ruin your integrity.

[toc] | [prev] | [next] | [standalone]


#18762

From"Evertjan." <exxjxw.hannivoort@inter.nl.net>
Date2013-03-08 00:42 +0100
Message-ID<XnsA17D732DFA7eejj99@194.109.133.133>
In reply to#18760
Daniel Pitts wrote on 08 mrt 2013 in comp.lang.javascript:

> Always assume 
> that the client is going to do everything it can to ruin your integrity.

I like that assumption.

However don't underestimate some programmer's urge for [self]destructive 
programming.

PS: Do you see the client as an "it"?

-- 
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

[toc] | [prev] | [next] | [standalone]


#18763

FromDaniel Pitts <newsgroup.nospam@virtualinfinity.net>
Date2013-03-07 15:55 -0800
Message-ID<jO9_s.63643$I12.60573@newsfe16.iad>
In reply to#18762
On 3/7/13 3:42 PM, Evertjan. wrote:
> Daniel Pitts wrote on 08 mrt 2013 in comp.lang.javascript:
>
>> Always assume
>> that the client is going to do everything it can to ruin your integrity.
>
> I like that assumption.
>
> However don't underestimate some programmer's urge for [self]destructive
> programming.
>
> PS: Do you see the client as an "it"?
>
I see the client as the web-browser infected with viruses and trojans 
designed intelligently to exploit any weakness you have left vulnerable 
on your server :-)

At some point, you have to trust the client to do what it is told, but 
the server you (should) have control over. Business invariants must be 
enforced on the server side, as the client side is vulnerable to 
manipulation.

[toc] | [prev] | [next] | [standalone]


#18765

Fromjustaguy <lichunshen84@gmail.com>
Date2013-03-07 16:43 -0800
Message-ID<8ca39b18-36ed-43f4-b196-922a8344de4b@googlegroups.com>
In reply to#18763
Ok.  Now, probably my customer's site is using php (they use WordPress), and I'm not a php programmer.  Question (allow me), does php have a way to pass
submitted form data to a remote script, say,
http://111.222.333.444/remoteScript
(that's my server side script).

Thanks.


>On Thursday, March 7, 2013 6:55:59 PM UTC-5, Daniel Pitts wrote:
> On 3/7/13 3:42 PM, Evertjan. wrote:
> 
> > Daniel Pitts wrote on 08 mrt 2013 in comp.lang.javascript:
> 
> >
> 
> >> Always assume
> 
> >> that the client is going to do everything it can to ruin your integrity.
> 
> >
> 
> > I like that assumption.
> 
> >
> 
> > However don't underestimate some programmer's urge for [self]destructive
> 
> > programming.
> 
> >
> 
> > PS: Do you see the client as an "it"?
> 
> >
> 
> I see the client as the web-browser infected with viruses and trojans 
> 
> designed intelligently to exploit any weakness you have left vulnerable 
> 
> on your server :-)
> 
> 
> 
> At some point, you have to trust the client to do what it is told, but 
> 
> the server you (should) have control over. Business invariants must be 
> 
> enforced on the server side, as the client side is vulnerable to 
> 
> manipulation.

[toc] | [prev] | [next] | [standalone]


#18767

FromStefan Weiss <krewecherl@gmail.com>
Date2013-03-08 02:55 +0100
Message-ID<khbgf5$6io$1@news.albasani.net>
In reply to#18765
On 2013-03-08 01:43, justaguy wrote:
> Ok. Now, probably my customer's site is using php (they use
> WordPress), and I'm not a php programmer. Question (allow me), does php
> have a way to pass submitted form data to a remote script, say,
> http://111.222.333.444/remoteScript
> (that's my server side script).

Then do it the other way around. Have the form submit to your new URL
and send a call to the legacy URL from your own server-side script.

Daniel is right that you shouldn't trust the client to successfully send
two requests in sequence. Even with a server-side approach, you'll have
to find a way to make sure that the two actions will be performed as one
transaction (i.e., either both or none).

If you absolutely have to do it from the client side, forget about
submitting the same form twice - that won't work (reliably). Have your
submit handler send an XHR to one of the URLs, and after you get the
response from that, submit() the form to the other URL.


Please stop top-posting, and try to quote only the text you're referring to.


- stefan

[toc] | [prev] | [next] | [standalone]


#18769

Fromjustaguy <lichunshen84@gmail.com>
Date2013-03-07 18:09 -0800
Message-ID<bff73e7f-101e-4ccd-bdf7-70b01d09824e@googlegroups.com>
In reply to#18767
On Thursday, March 7, 2013 8:55:48 PM UTC-5, Stefan Weiss wrote:
> On 2013-03-08 01:43, justaguy wrote:
> 
> > Ok. Now, probably my customer's site is using php (they use
> 
> > WordPress), and I'm not a php programmer. Question (allow me), does php
> 
> > have a way to pass submitted form data to a remote script, say,
> 
> > http://111.222.333.444/remoteScript
> 
> > (that's my server side script).
> 
> 
> 
> Then do it the other way around. Have the form submit to your new URL
> 
> and send a call to the legacy URL from your own server-side script.
> 
> 
> 
> Daniel is right that you shouldn't trust the client to successfully send
> 
> two requests in sequence. Even with a server-side approach, you'll have
> 
> to find a way to make sure that the two actions will be performed as one
> 
> transaction (i.e., either both or none).
> 
> 
> 
> If you absolutely have to do it from the client side, forget about
> 
> submitting the same form twice - that won't work (reliably). Have your
> 
> submit handler send an XHR to one of the URLs, and after you get the
> 
> response from that, submit() the form to the other URL.
> 
> 
> 
> 
> 
> Please stop top-posting, and try to quote only the text you're referring to.
> 
> 
> 
> 
> 
> - stefan

"Then do it the other way around. Have the form submit to your new URL 
and send a call to the legacy URL from your own server-side script. "
Nope.  Their existing process takes higher priority, hence, their first.

"
> Please stop top-posting, and try to quote only the text you're referring to.
"
Sorry about that.

[toc] | [prev] | [next] | [standalone]


#18770

FromStefan Weiss <krewecherl@gmail.com>
Date2013-03-08 04:21 +0100
Message-ID<khblfe$hr8$1@news.albasani.net>
In reply to#18769
On 2013-03-08 03:09, justaguy wrote:
> On Thursday, March 7, 2013 8:55:48 PM UTC-5, Stefan Weiss wrote:
>> Then do it the other way around. Have the form submit to your new URL
>> and send a call to the legacy URL from your own server-side script.

> Nope.  Their existing process takes higher priority, hence, their first.

So call their URL from your script before you do your thing?

- The HTML form is submitted to your URL
- Your script
    - calls their process URL, passing along the form values
    - if it gets a success response
        - writes something to the database
    - handles errors as necessary
    - sends response

> "
>> Please stop top-posting, and try to quote only the text you're referring to.
> "
> Sorry about that.

That wasn't quite what I had in mind :)

Now you've quoted everything, and then the parts you replied to - again.
Take a look here: http://learn.to/quote
Especially part 2 about Quoting and Answering.

Unfortunately, Google Groups is a very poor Usenet client. I don't use
it for posting, but I checked (just in case), and it's possible to quote
correctly, even with GG. You need to remove as many of the lines
starting with ">" as necessary, until you're left with what you want to
quote.


- stefan

[toc] | [prev] | [next] | [standalone]


#18771

Fromjustaguy <lichunshen84@gmail.com>
Date2013-03-07 19:37 -0800
Message-ID<21d339f3-f3c7-4169-aae8-e49532e825c9@googlegroups.com>
In reply to#18770
On Thursday, March 7, 2013 10:21:17 PM UTC-5, Stefan Weiss wrote:
> On 2013-03-08 03:09, justaguy wrote:
> 
> > On Thursday, March 7, 2013 8:55:48 PM UTC-5, Stefan Weiss wrote:
> 
> >> Then do it the other way around. Have the form submit to your new URL
> 
> >> and send a call to the legacy URL from your own server-side script.
> 
> 
> 
> > Nope.  Their existing process takes higher priority, hence, their first.
> 
> 
> 
> So call their URL from your script before you do your thing?
> 
> 
> 
> - The HTML form is submitted to your URL
> 
> - Your script
> 
>     - calls their process URL, passing along the form values
> 
>     - if it gets a success response
> 
>         - writes something to the database
> 
>     - handles errors as necessary
> 
>     - sends response
>
> - stefan

You confused me here. My script calling their form process script (say, 111.222.333.444/formProcess.php) does not mean anything, that is, my understanding is that my remote script won't be able to retrieve any dynamically filled form data from their site.

On the other hand, for their script, the end of their script, if they have a way to embed form data and send it long to my remote script with or without href/http redirection that would suffice.  Don't think it's a cleaner solution?

Thanks.

[toc] | [prev] | [next] | [standalone]


#18773

FromStefan Weiss <krewecherl@gmail.com>
Date2013-03-08 13:18 +0100
Message-ID<khcku1$264$1@news.albasani.net>
In reply to#18771
On 2013-03-08 04:37, justaguy wrote:
> On Thursday, March 7, 2013 10:21:17 PM UTC-5, Stefan Weiss wrote:
>> So call their URL from your script before you do your thing?
>> 
>> - The HTML form is submitted to your URL
>> - Your script
>>     - calls their process URL, passing along the form values
>>     - if it gets a success response
>>         - writes something to the database
>>     - handles errors as necessary

> You confused me here. My script calling their form process script
> (say, 111.222.333.444/formProcess.php) does not mean anything, that is,
> my understanding is that my remote script won't be able to retrieve any
> dynamically filled form data from their site.

It's just HTTP. Your new script could pass along whatever was sent from
the browser (form data, cookies) to the existing script.

> On the other hand, for their script, the end of their script, if
> they have a way to embed form data and send it long to my remote script with
> or without href/http redirection that would suffice. Don't think it's a
> cleaner solution?

Possibly, but you said that was a WordPress script, and you didn't want
to do PHP programming.

To be honest, the whole setup looks overcomplicated. You're writing a
web application with two separate backends, two server-side languages
(PHP and whatever you're using), and two databases (one for WordPress
and one for your client's orders)? I don't know enough about your
project to advise, but if you're extending an existing WP installation,
the path of least resistance might be writing a custom WP plugin.

- stefan

[toc] | [prev] | [next] | [standalone]


#18778

FromThomas 'PointedEars' Lahn <PointedEars@web.de>
Date2013-03-08 20:51 +0100
Message-ID<2029941.ODgsEiv6zD@PointedEars.de>
In reply to#18752
Danny wrote:

> To justaguy
> 
> usually, you don't need to submit a form twice, you have the script on the
> server handle the double processing on 1 submit from the client only. 
> That said, what's action1.html and action2.html supposed to do?

Is there even a *remote* chance that you read the FAQ of this newsgroup and 
start posting properly?  Just asking.

-- 
PointedEars

Twitter: @PointedEars2
Please do not Cc: me. / Bitte keine Kopien per E-Mail.

[toc] | [prev] | [next] | [standalone]


#18754

From"Evertjan." <exxjxw.hannivoort@inter.nl.net>
Date2013-03-07 23:52 +0100
Message-ID<XnsA17CF2D07AD8Feejj99@194.109.133.133>
In reply to#18750
justaguy wrote on 07 mrt 2013 in comp.lang.javascript:

> 
> Is it possible?  If so, the following script does not work, what's
> wrong?  Thanks. 
> 
> <script type="text/javascript">
>      
>      function doubleSubmit(f)
>           {
>             // submit to action in form
>             f.submit();
>             // return false;
>             
>             // set second action and submit
>             // f.target="_blank";
>             f.action="action2.html";            
>             f.submit();
>             // return false;
>           }
> 
> </script>
> 
> <form name="checkout" method="post" action="action1.html"
> onsubmit="doubleSubmit(this)"> 
>      <input type="text" name="customer">
>      <input type="hidden" name="dev" value="test">
>      <input type="submit" name="send" value="Place Order">
> </form>

If you submit without specifying a target,
your page will be overwritten, 
and there can be no second submit.

Don't forget the return in onsubmit,
ortherwise you get 3 submits, 
methinks.

<script type="text/javascript">
function doubleSubmit(f) {
  f.method = 'post';
  f.target = 'anotherPage';
  f.action = 'action1.html';		  
  f.submit();
  f.method = 'get'; // ! ;-)
  f.action = 'action2.html';		  
  f.submit();
  return false;
};
</script>

<form onsubmit = 'return doubleSubmit(this)'>
...........

-- 
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

[toc] | [prev] | [next] | [standalone]


#18758

Fromjustaguy <lichunshen84@gmail.com>
Date2013-03-07 15:16 -0800
Message-ID<df2aecfa-053e-4b2b-aa6e-962e16acecc5@googlegroups.com>
In reply to#18750
Hi,

Thanks.  Your code makes more sense.  I changed the   
f.method = 'get'; // ! ;-) 
to
'POST' method because I don't want form data to show up at URL level.

Outcome:
it brought up another tab for action2.html
but action1.html has not been processed.

Tested with Chrome 25, Safari 5.05 and Firefox 19.

Any further thoughts?


>On Thursday, March 7, 2013 4:18:19 PM UTC-5, justaguy wrote:
> Is it possible?  If so, the following script does not work, what's wrong?  Thanks.
> 
> 
> 
> <script type="text/javascript">
> 
> 	
> 
> 	function doubleSubmit(f)
> 
> 		{
> 
> 		  // submit to action in form
> 
> 		  f.submit();
> 
> 		  // return false;
> 
> 		  
> 
> 		  // set second action and submit
> 
> 		  // f.target="_blank";
> 
> 		  f.action="action2.html";		  
> 
> 		  f.submit();
> 
> 		  // return false;
> 
> 		}
> 
> 
> 
> </script>
> 
> 
> 
> <form name="checkout" method="post" action="action1.html" onsubmit="doubleSubmit(this)">
> 
> 	<input type="text" name="customer">
> 
> 	<input type="hidden" name="dev" value="test">
> 
> 	<input type="submit" name="send" value="Place Order">
> 
> </form>

[toc] | [prev] | [next] | [standalone]


#18759

FromDanny <dann90038@gmail.com>
Date2013-03-07 15:22 -0800
Message-ID<3fe91b07-befa-4d1b-8f01-0fc7701ee459@googlegroups.com>
In reply to#18758
To Tony

As already suggested, give both actions a 'target' container, the ol' trick is to use a hidden iframe(s) for submission, the user stays on the page [you can add a progress bar or DONE/Thankyou message], while submitting on the background.  You could also just use a hidden form :|, and do a .submit() on it no need to do the reassigning for .action, since I think you may get into submit-timing issues.

[toc] | [prev] | [next] | [standalone]


#18761

From"Evertjan." <exxjxw.hannivoort@inter.nl.net>
Date2013-03-08 00:37 +0100
Message-ID<XnsA17D65C2F1DBeejj99@194.109.133.133>
In reply to#18758
justaguy wrote on 08 mrt 2013 in comp.lang.javascript:

> Thanks.  Your code makes more sense.  I changed the   
> f.method = 'get'; // ! ;-) 
> to
> 'POST' method because I don't want form data to show up at URL level.

I just showed the possibility, if both are post, 
you surely don't have to specify it twice.

> Outcome:
> it brought up another tab for action2.html
> but action1.html has not been processed.

I don't think so,
if the target is named but not '_blank',
the same window should have beeen used.

And,
you cannot specify from the page 
wether a tab or a new window will be used.

A named <iframe> is a possibility.

> 
> Tested with Chrome 25, Safari 5.05 and Firefox 19.
> 
> Any further thoughts?
> 

Perhaps you should give the second posting a timeOut() of say 50
miliseconds, to have the browser recover from this rather unusual request, 
never yet envisaged by the browser-makers?

-- 
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

[toc] | [prev] | [next] | [standalone]


#18766

Fromjustaguy <lichunshen84@gmail.com>
Date2013-03-07 16:44 -0800
Message-ID<976811f3-08a2-4bd3-b6d3-5ea0f08c12c0@googlegroups.com>
In reply to#18761
I got inconsistent results, FF is better, Chrome not working.  Plus, most argue that client side for this isn't a good idea, so, I'm exploring server side solution now.  Thanks.

>On Thursday, March 7, 2013 6:37:30 PM UTC-5, Evertjan. wrote:
> justaguy wrote on 08 mrt 2013 in comp.lang.javascript:
> 
> 
> 
> > Thanks.  Your code makes more sense.  I changed the   
> 
> > f.method = 'get'; // ! ;-) 
> 
> > to
> 
> > 'POST' method because I don't want form data to show up at URL level.
> 
> 
> 
> I just showed the possibility, if both are post, 
> 
> you surely don't have to specify it twice.
> 
> 
> 
> > Outcome:
> 
> > it brought up another tab for action2.html
> 
> > but action1.html has not been processed.
> 
> 
> 
> I don't think so,
> 
> if the target is named but not '_blank',
> 
> the same window should have beeen used.
> 
> 
> 
> And,
> 
> you cannot specify from the page 
> 
> wether a tab or a new window will be used.
> 
> 
> 
> A named <iframe> is a possibility.
> 
> 
> 
> > 
> 
> > Tested with Chrome 25, Safari 5.05 and Firefox 19.
> 
> > 
> 
> > Any further thoughts?
> 
> > 
> 
> 
> 
> Perhaps you should give the second posting a timeOut() of say 50
> 
> miliseconds, to have the browser recover from this rather unusual request, 
> 
> never yet envisaged by the browser-makers?
> 
> 
> 
> -- 
> 
> Evertjan.
> 
> The Netherlands.
> 
> (Please change the x'es to dots in my emailaddress)

[toc] | [prev] | [next] | [standalone]


#18782

FromDenis McMahon <denismfmcmahon@gmail.com>
Date2013-03-09 05:09 +0000
Message-ID<kheg70$at3$4@dont-email.me>
In reply to#18758
On Thu, 07 Mar 2013 15:16:29 -0800, justaguy wrote:

> Any further thoughts?

What happens if the client is using Lynx? Or just has javascript disabled?

Rgds

Denis McMahon

[toc] | [prev] | [next] | [standalone]


#18777

FromThomas 'PointedEars' Lahn <PointedEars@web.de>
Date2013-03-08 20:50 +0100
Message-ID<1572630.hS600URIVS@PointedEars.de>
In reply to#18750
justaguy wrote:

> Is it possible

Is what possible?

> If so, the following script does not work,

“Does not work” is not a problem description.  Read the FAQ.

> what's wrong? 
> 
> <script type="text/javascript">
> 
> function doubleSubmit(f)
> {
> // submit to action in form
> f.submit();
> // return false;
> 
> // set second action and submit
> // f.target="_blank";
> f.action="action2.html";
> f.submit();
> // return false;
> }

If you submit a form so that the result is displayed in the same view 
(window, frame etc.), the document containing the source code is unloaded 
(the same as if you navigate away).  In short, code in that document that is 
located after the call during execution is not necessarily available 
anymore.

-- 
PointedEars

Twitter: @PointedEars2
Please do not Cc: me. / Bitte keine Kopien per E-Mail.

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.javascript


csiph-web