469,270 Members | 1,117 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,270 developers. It's quick & easy.

javascript document.form.submit()

3
i am trying to submit the form multipple times
within a loop, if i have an alert() coded, it works,
but, when i take the alert() out, it only does the submit the last time through the loop.
Apr 30 '06 #1
5 70408
Banfa
9,064 Expert Mod 8TB
Post the code, by your own admission it is faulty but we will have great trouble divining that fault without site of the code.
Apr 30 '06 #2
therjs
3
Expand|Select|Wrap|Line Numbers
  1. function doVote() 
  2. {
  3.     var index = 0;
  4.  
  5.     index = document.f1.numVoteItems.value;
  6.  
  7.     document.f1.action="../Parts/GeneralInfo";
  8.     document.f1.actionName.value = "DOVOTE";
  9.  
  10.      var yesRadio;
  11.     var noRadio;
  12.     var j = 1;
  13.  
  14.     for (var i = 0; i < index; i++) 
  15.     {
  16.         eval("yesRadio=document.f1.YesRadio" + j);
  17.         eval("noRadio=document.f1.NoRadio" + j);
  18.  
  19.         eval("res=document.f1.resPartNumber" + i);
  20.         eval("req=document.f1.reqPartNumber" + i);
  21.  
  22.         if (yesRadio.checked == true)
  23.         {
  24.             //alert("yes radio is checked");
  25.             document.f1.reqPartNumber.value = req.value;
  26.             document.f1.resPartNumber.value = res.value;
  27.             document.f1.vote.value = "Y";
  28.             document.f1.submit();
  29.             //alert('should have done an update');
  30.         }
  31.  
  32.         if (noRadio.checked == true)
  33.         {
  34.             //alert("no radio is checked");
  35.             document.f1.reqPartNumber.value = req.value;
  36.             document.f1.resPartNumber.value = res.value;
  37.             document.f1.vote.value = "N";
  38.             document.f1.submit();
  39.             //alert('should have done an update');
  40.         }
  41.  
  42.         j = j + 1;
  43.     }
  44. }
May 1 '06 #3
Banfa
9,064 Expert Mod 8TB
I suspect (although I don't know) that you are running some sort of undefined behaviour. I do not think that you are supposed to be able to submit a single form multiple times because as soon as you submit a form you start loading the result of that submission.

Quite how you would see the results of multiple submission I am not sure.

I suspect in the case of having the alerts in that the form being submitted is not being cleared striaght away indavertently allowing it to be submitted multiple times in the version of the browser you are using. I suspect this is a feature rather than designed behaviour and that you are not garunteed that it will always be there in a new version or different browser.

Looking at you code it looks like all the information required is on the form and without knowing more about what you are trying to achieve I would say that it should be possible to do what you want from a single submit letting the receiving page handle sorting out all the data server side rather than trying to do it client side.
May 2 '06 #4
therjs
3
well, i think that i need to set up the receiving servlet to handle an array of values, rather than trying to submit the form multiple times.
May 2 '06 #5
Banfa
9,064 Expert Mod 8TB
well, i think that i need to set up the receiving servlet to handle an array of values, rather than trying to submit the form multiple times.
I agree :)
May 2 '06 #6

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

4 posts views Thread by houstoncity2004 | last post: by
11 posts views Thread by Brian D | last post: by
10 posts views Thread by ljlolel | last post: by
14 posts views Thread by Mtek | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.