oh ok, that makes sense now, thanks (:

----- Original Message ----- 
From: "John McGowan" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, April 15, 2004 2:56 PM
Subject: Re: Witango-Talk: Select a submit button in a form (OT)


> It's a basic race condition...
>
> Like I said it depends on the event handlers being multithreaded...
> Take a look at the code with line numbers...
>
> 1: var submitted=false;
> 2: function checkSubmit()
> 3: {
> 4:  if (submitted==false)
> 5:  {
> 6:    sunmitted=true;
> 7:    return true;
> 8:  }
> 9:  else
> 10:  {
> 11:    alert('Already submitted');
> 12:    return false;
> 13: }
> 14:}
>
> If click 1 spawns thread A and click 2 spawns thread B
>
> If thread A gets to Line 5: and then processing is handed over to thread
B,
> Thread Be will be able to get to Line 5: as well...
>
> /John
>
> Alan Wolfe wrote:
>
> >could you explain how they could both get caught in the false case?
> >
> >it looks ok to me so just wondering what im missing
> >
> >----- Original Message ----- 
> >From: "John McGowan" <[EMAIL PROTECTED]>
> >To: <[EMAIL PROTECTED]>
> >Sent: Thursday, April 15, 2004 2:43 PM
> >Subject: Re: Witango-Talk: Select a submit button in a form (OT)
> >
> >
> >
> >
> >>Dave Shelley wrote:
> >>
> >>
> >>
> >>>Steve,
> >>>
> >>>On your form tag, add onSubmit="return(checkSubmit())"
> >>>and add a javascript function that says:
> >>>
> >>>var submitted=false;
> >>>function checkSubmit()
> >>>{
> >>> if (submitted==false)
> >>> {
> >>>   sunmitted=true;
> >>>   return true;
> >>> }
> >>> else
> >>> {
> >>>   alert('Already submitted');
> >>>   return false;
> >>> }
> >>>}
> >>>
> >>>That should do it.
> >>>
> >>>
> >>>
> >>>
> >>As long as the Javascript event handlers aren't threaded.  If they were
> >>threaded, both threads could make it into the "if submitted==false"
branch
> >>
> >>I wouldn't be suprised if the javascript event handlers were threaded,
> >>because otherwise an infinite loop in one could cause some serious
> >>
> >>
> >problems.
> >
> >
> >>/John
> >>
> >>
> >>
> >>________________________________________________________________________
> >>TO UNSUBSCRIBE: Go to http://www.witango.com/developer/maillist.taf
> >>
> >>
> >
> >________________________________________________________________________
> >TO UNSUBSCRIBE: Go to http://www.witango.com/developer/maillist.taf
> >
> >
> >
>
> ________________________________________________________________________
> TO UNSUBSCRIBE: Go to http://www.witango.com/developer/maillist.taf

________________________________________________________________________
TO UNSUBSCRIBE: Go to http://www.witango.com/developer/maillist.taf

Reply via email to