By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,700 Members | 1,512 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,700 IT Pros & Developers. It's quick & easy.

form.submit sometimes does not work!

P: 4
There are 3 buttons on a web page. On clicking each button a same popup window (say window1) opens up. Now there is another button on this popup window (window1), which further opens up to another popup window (say window2). On selecting some value from the 'window2', that value is passed onto the 'window1'. There is a 'Find' link on a 'window1', which calls a javascript function 'clicked()':

Expand|Select|Wrap|Line Numbers
  1.     <head>
  2.     <%
  3.       Dim command
  4.       command = Request.Form("hid");
  5.       Response.Write(“Value” & command);  -- The value is not printed (Reason found after 
  6.                                                    analysis that may be because the form is not submitted 
  7.                                                     successfully)
  8.     %>
  9.  
  10.     function clicked()
  11.     {
  12.        document.form.hid.value='FIND';
  13.        alert("before");              -- This message box appears
  14.        document.form.submit();  -- after a lot of analysis the conclusion is that 
  15.                                   this submit statement stops working (as on the status   
  16.                                   bar 'Opening https:.....File1.asp?form=...' is not 
  17.                                   displayed when 'after' message box appears
  18.        alert("after");               -- This message box appears 
  19.     }
  20.  
  21.     <body.......>
  22.     <% if command = "FIND" then
  23.        Response.Write ("Inside Find"); -- This message is not printed.
  24.       // some functonality
  25.  
  26.     %>
  27.     <form ....>
  28.  
  29.        <input type="hidden" name="hid" value="">
  30.  
  31.     </form>
  32.     </body>
This full code works fine on my machine. But this code does not work properly when run on the client-side!, although the same server and the same deployed application is being accessed. There is no particular sequence/scenario but for eg.
When say button1 clicked->window1 opens->window2 is opened->value selected->returned to window1->Clicked on Find-> clicked on Ok->returned on the main page.
Then repeated the same scenario for say 3rd button.
(Till now 'Find' link works fine).
Now repeated the same scenario for 2nd button and here 'after' message is obtained but 'inside Find' is not printed!!
Feb 20 '10 #1
Share this Question
Share on Google+
5 Replies


gits
Expert Mod 5K+
P: 5,390
hmmm ... i think i don't get it right ... could you rephrase that question so that it would be a bit more clear ... when is what and how passed between different windows? are those windows real popup windows?

kind regards
Feb 26 '10 #2

P: 4
What should happen: On clicking 'Find' link some records are retrieved from the database and displayed on the very same popup window. Now further on clicking 'Ok' the popup window closes and all the retrieved records are populated in a list box on the main page (where there were 3 buttons).

What happens is: The above scenario does happen once or twice but the 3rd or the 4th time what happens is that on clicking 'Find', no records are retrieved and it goes to wait state. It sort of hangs. None of the links work any further, even the ones on the main page stop working. The window2 also doesn't open, blank page is displayed.

In my first post, in the code, i have added the comments of exactly which all alerts/Response.Write are shown and which are not, when the problem occurs.

Yes it seems the browser does not load, the page does not get refreshed. (When the 1st or the 2nd time 'Find' works fine, the page does get refreshed.)
I can't hit anything on the current session anymore!

After a lot of analysis, we have come to this conclusion that probably 'Find' link does not work after sometime because of some memory/buffer issue. I am using a 'for' loop which concatenates the strings retrieved on clicking 'Find' from the database.

Expand|Select|Wrap|Line Numbers
  1. var concatstr = "";
  2. for(i = 0 ; i < arr.length ; i++)
  3. {
  4.      concatstr += arr[i]+";";
  5. }
  6. parent.opener.mainform.txtbx.value=concatstr; // transferring the semicolon separated string to the main form, where there are the 3 buttons 
  7.  
(mainform - is the webpage where there are these 3 buttons.)
(arr - is the array that stores all the retrieved strings from the database on clicking 'Find' link.)

Probably a number of string objects are getting created and filling the buffer. What do u say?
(On an average around 15 strings are retrieved each time)
Probably which is why the 'request' is getting 'blocked'! It goes to wait state.

No other link works as their URL don't work any further (the request is not going through, may be because of the previous pending request [Find link click]), only 'cancel' link works since it has only one statement written : "parent.close" (nothing to do with request,response).

Is it so that the concatenation described above is creating 15! string objects (read as 15 factorial string objects) and thereby causing the block?
Feb 27 '10 #3

gits
Expert Mod 5K+
P: 5,390
that small number of string-objects doesn't seem to be an issue that might cause such a problem ... but i cannot see some other obvious thing at the moment. might be to try that all in firefox and have a look at the firebug console might show more info ... i suspect a fatal javascript error that might block the submit then ... it could be a strange return-value that might break the concat-logic or similar ... for example some quotes or double qoutes in the response or something like that?

kind regards
Mar 1 '10 #4

P: 4
@gits
I will definitely try this out, that you have suggested.

Some more information about the code:
We are opening and closing connection on each opening of the popup window. (opening-closing, opening-closing, opening-closing, .....).
Can this be also an overhead?

I am posting some code portions also for your reference :

Expand|Select|Wrap|Line Numbers
  1. // When Ok button is clicked and the popup window closes after concatenating the string names and ids retrieved. After closing the listbox appears on the main page with the string names retrieved.
  2. function clickedOk()
  3. {
  4.    var input1="<select name='myselect' style='width:435;' id='"+btnname+"lboxId' multiple>";         
  5.  
  6.    var input2=new StringBuffer();     
  7.    var concatenated_pooloid = new StringBuffer(); 
  8.    var concatenated_poolnames = new StringBuffer();
  9.  
  10.    for(i=0;i<val.length;i++)
  11.    { 
  12.      input2=input2.append("<option value='"+ (i+1) +"'>"+ val[i] +"</option>");        
  13.      concatenated_pooloid.append(val[i]+";"); 
  14.      concatenated_poolnames.append(val1[i]+";");
  15.    } 
  16.  
  17.     var btn = "clearbutton"+btnname;
  18.     var listbox = btnname+"lboxId";
  19.     var imagebtn = "myIMGOk"+btnname;
  20.  
  21. parent.opener.document.getElementById(names_divID).innerHTML = "";                                     
  22. parent.opener.document.getElementById(names_divID).innerHTML = parent.opener.document.getElementById(names_divID).innerHTML + "&nbsp;&nbsp;<img id='myIMGOk"+btnname+"' style='color: blue; text-decoration: underline; cursor: pointer;font-family: verdana;font-size: 7pt' 
  23. src='/images/ok_arrow.gif' border='0' />" +"&nbsp;<a id='clearbutton"+btnname+"' href=java-script:clearListBox('"+btn+"','"+listbox+"','"+names_divID+"','"+const_IDs+"','"+const_NAMES+"','"+imagebtn+"')><u>Clear</u></a>";
  24.  
  25. parent.opener.document[const_FORMNAME][const_IDs].value = concatenated_pooloid+";";     
  26. parent.opener.document[const_FORMNAME][const_NAMES].value = concatenated_poolnames+";"; 
  27. parent.opener.document.getElementById(names_divID).style.display = "inline";      
  28.  
  29. parent.close();
  30. }
  31.  
  32. function StringBuffer() {  
  33.    this.buffer = [];  
  34.  }  
  35.  
  36.  StringBuffer.prototype.append = function append(string) {  
  37.    this.buffer.push(string);  
  38.    return this;  
  39.  };  
  40.  
  41.  StringBuffer.prototype.toString = function toString() {  
  42.    return this.buffer.join("");  
  43.  };  
  44.  
  45.  function validateAndSubmit() {            
  46.                 document.resourcePickerForm.hidCommand.value =  "FIND";
  47.                 document.resourcePickerForm.action =  "popupWnd.asp?............";   // ....... means parameters
  48.                 document.resourcePickerForm.submit();
  49.     }
  50.  
  51. <script type="text/java-script">
  52.  
  53.     // Global Variable Declaration
  54.     var countTextBox = 0;
  55.     var tempcount = 0;
  56.     var totalSelected = 0;
  57.  
  58.     var selectedArray = new Array();
  59.     var selectedArray1 = new Array();
  60.     var count=0;
  61.     var val = new Array();
  62.     var val1 = new Array();
  63.  
  64.     var const_FORMNAME='<%=(Request.QueryString("FormName"))%>';
  65.  
  66.  
  67. // This is called after checking the checkboxes displayed with retrieved strings and transferring them on the right-side of the page, the ones which we want to pass on the main page (displayed inside the listbox).
  68. function transfer()
  69. {         
  70.    // Finding which checkboxes are checked and then adding them.
  71.    var i=0;  
  72.    while(document.getElementById("chkbox"+i))
  73.    {   
  74.     if(document.getElementById("chkbox"+i))
  75.     {    
  76.        if (document.getElementById("chkbox"+i).checked)
  77.        {  
  78.                 var inputTag = document.createElement ("input");
  79.                 var type = "text";
  80.                 inputTag.setAttribute("text",type);
  81.                 inputTag.setAttribute("value",selectedArray[i]);             
  82.                 inputTag.setAttribute("name",type+count);
  83.                 inputTag.setAttribute("size",45);
  84.                 inputTag.setAttribute("font-size",8);        
  85.                 inputTag.setAttribute("id","strText"+count);
  86.                 val[count]=selectedArray[i];   // Filling names  into array val                                 
  87.                 val1[count]=selectedArray1[i]; // Filling ids  into array val1                    
  88.  
  89.                 document.getElementById('RightFrame').innerHTML  = document.getElementById('RightFrame').innerHTML + "<br  id='br"+count+"'>&nbsp;&nbsp;&nbsp;&nbsp;<input type='checkbox'  id='RFchkbox" + count + "' name='RFchkbox" + count + "'  visible='true' />&nbsp;<input type='text'  style='font-size:10;font-family:Verdana;' id='strText"+count+"'  value='"+selectedArray[i]+"' size='50' readonly='readonly'/>"    
  90.  
  91.                   count++;
  92.               }                                     
  93.         document.getElementById("chkbox"+i).checked="";
  94.         }            
  95.      }
  96.      i++;      
  97.      document.getElementById("C1").checked="";            
  98.    }
  99. }
  100.  
  101. </script>
  102.  
  103.  
  104.     <%
  105.         Dim command         
  106.         command = Request.Form("hidCommand")                
  107.     %>
  108.  
  109.     <%
  110.       Sub ChildDisplay(poolOID)
  111.  
  112.       Set LocalRS = Server.CreateObject("ADODB.RecordSet")
  113.       strSQL="select name,id,..................."
  114.  
  115.       LocalRS.Open strSQL, Conn
  116.  
  117.       If Not LocalRS.EOF Then
  118.  
  119.          LocalRS.MoveFirst 
  120.          j = 0 
  121.     %>
  122.     <%
  123.             Do While LocalRS.EOF <> True
  124.     %>
  125.     <tr>
  126.         <td width="2%" style="border:solid 1px  #6c9fc6;border-top:0;">
  127.             <font size="1" face="Verdana">
  128.                 <input type="checkbox" id="chkbox<%= j %>"  name="C2" value="<% = LocalRS.Fields(0).value %>"  on-cl-ick='java-script:setSelected("<%=LocalRS.Fields(0).val ue %>", "<% = LocalRS.Fields(2).value %>","<%= j %>")'></font>
  129.                 <input type="hidden" id="PoolId<%= j %>"  value="<% = LocalRS.Fields(2).value %>" />
  130.          </td>
  131.         <td width="50%" style="border:solid 1px  #6c9fc6;border-top:0;border-left:0;" >
  132.             <font face="Verdana" size="1">
  133.                 <% = LocalRS.Fields(0).value %>
  134.             </font>
  135.         </td>  
  136.      </tr>
  137.     <%
  138.     j = j + 1
  139.                   LocalRS.MoveNext
  140.                   If LocalRS.EOF = True then 
  141.                         exit do     
  142.                   end if
  143.             loop
  144.       %>
  145.     <%
  146.       end if
  147.       LocalRS.Close     
  148.       Set LocalRS=nothing                                   
  149. End Sub
  150.     %>
  151.  
  152. <body style="background-color: #fcfefd">
  153.     <!-- #include virtual="/config/DataSource.asp"  -->
  154.     <% if command = "FIND" then 
  155.     %>
  156.     <%
  157.       Dim Conn          ' Connection Variable
  158.       Dim RS             ' Result Set Variable
  159.       Dim strSQL       ' SQL Query String
  160.  
  161.       Set Conn = Server.CreateObject("ADODB.Connection")
  162.       Set RS = Server.CreateObject("ADODB.RecordSet")
  163.  
  164.       locName = Request.Form("location") 
  165.       strSQL = "select name, id from table1 where location ='"+locName+"'"
  166.  
  167.       Conn.Open  SSdsn, SSdbuser, SSdbpass
  168.  
  169.       RS.Open strSQL, Conn    
  170.  
  171.       If Not RS.EOF Then
  172.             RS.MoveFirst
  173.       End If                 
  174.     %>
  175.     <% end if %>
  176.  
  177.     <form name="popupWndForm" action="" method="post">
  178.  
  179.         <input type="hidden" id="hidCommand" name="hidCommand"  value="" />
  180.         <a href="java-script:transfer()">Transfer</a>  
  181.         <a  href="java-script:validateAndSubmit()">Find</a>
  182.         <a href="java-script:clickedOk()">OK</a>  
  183.  
  184.          <div class="leftframe">
  185.             <% if command = "FIND" then            
  186.             %>
  187.  
  188.             <table id="table1" height="30" cellspacing="0">
  189.                 <!-- MSTableType="nolayout" -->
  190.                 <tr>
  191.                     <td bgcolor="#c2d6e7" style="border:solid  1px #6c9fc6;">
  192.                         <input type="checkbox" name="C1"  value="yes" on-cl-ick="java-script:selectDeselectAll()"></td>
  193.                     <td bgcolor="#c2d6e7" style="border:solid  1px #6c9fc6; border-left:0">
  194.                         <b><font face="Verdana" size="1">Name</font></b></td>                                       
  195.                 </tr>
  196.                 <%
  197.                       ChildDisplay(RS.Fields(2))      
  198.                 %>
  199.             </table>
  200.  
  201.             <% end if %>
  202.           </div>  
  203.    </form>
  204.  
  205.     <% if command = "FIND" then 
  206.     %>
  207.     <%
  208.       RS.Close    
  209.       Conn.Close        
  210.       Set RS=nothing
  211.       Set Conn=nothing
  212.     %>
  213.     <% end if %>
  214.  
  215. </body>
  216. </html>
  217.  
Thanks in advance.
Mar 2 '10 #5

P: 4
The problem is similar to one that is mentioned here:
[url=http://www.justskins.com/forums/browser-hangs-when-posting-sometimes-85959.html]

"If we close the IE window, and start open a new one, then things start loading again. And this is pretty much the only way to get to the web site after this happens, is to restart IE. Any attempts in the original IE window hang."
Mar 2 '10 #6

Post your reply

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