Link to home
Start Free TrialLog in
Avatar of grishat
grishat

asked on

Popup Window loses it's parent form value (Operner.Document.FormName) on refresh

Hi, I have a popup window which returns values to the textboxes on the parent form when user clicks on 'Add Footnotes' button. The problem I'm having is that when the submit button is clicked the form is refreshed and the value of the Opener.Document.FormName loses it's value. So the value of the textbox can be returned to the parent form only once. How can I solve this? I'm new to this so your help would be greatly appreciated.. Here is the code:

This is the Parent Form button that calls the Popup
<input type="Button" value="Add" name="cmdFootNotesT1_2" onclick="window.open('FootNotes.asp?txtname1=T1_1_FootNoteID_2&txtname2=T1_2_FootNoteID_2&txtname3=T1_3_FootNoteID_2&txtname4=T1_4_FootNoteID_2&btnName=cmdFootNotesT1_2','PopUp','resizable=yes,width=800,height=600')">


Here is the popup form called "popForm":

<%txtname1=trim( Request.Form("txtname1") )%>
<%txtname2=trim( Request.Form("txtname2") )%>
<%txtname3=trim( Request.Form("txtname3") )%>
<%txtname4=trim( Request.Form("txtname4") )%>

<%
If Request.QueryString("txtname1")<>"" Then
      txtname1=Request.QueryString("txtname1")
End If
If Request.QueryString("txtname2")<>"" Then
      txtname2=Request.QueryString("txtname2")
End If
If Request.QueryString("txtname3")<>"" Then
      txtname3=Request.QueryString("txtname3")
End If
If Request.QueryString("txtname4")<>"" Then
      txtname4=Request.QueryString("txtname4")
End If
%>

<html>
<head>
      <title>Foot Notes</title>
      
<SCRIPT LANGUAGE="JavaScript">

function Getvalue()
{
opener.document.Form3Edit.<%=txtname1%>.value=document.popForm.Notes.value
opener.document.Form3Edit.<%=txtname2%>.value=document.popForm.Notes.value
opener.document.Form3Edit.<%=txtname3%>.value=document.popForm.Notes.value
opener.document.Form3Edit.<%=txtname4%>.value=document.popForm.Notes.value
}
</script>

</head>
<%Notes=trim( Request.Form("Notes") )%>
<%txtEditHidden=trim( Request.Form("txtEditHidden") )%>


<%IF Request("AddFootnote") = "Add Footnote" THEN      
      If Notes<>"" then            
            If txtEditHidden="Edit" Then                  
                  Conn.Execute "Update tblForm3_Footnotes Set Footnote='" & sqlBless(Notes) & "' WHERE ID=" & CInt(Request("OptionID"))
            Else                  
                  SET rsCounter = Server.CreateObject("ADODB.Recordset")
                  rsCounter.Open "Select Max(Counter) as MaxCounter from tblForm3_Footnotes Where GroupCode=" & Session("GroupCode"), Conn, 0
                  If rsCounter.EOF=True Or rsCounter.fields("MaxCounter").value="" Or isnull(rsCounter.fields("MaxCounter").value)=True Then
                        Conn.Execute "Insert Into tblForm3_Footnotes (GroupCode, Counter, Footnote) Values (" & Session("GroupCode") & ", 1, '" & sqlBless(Notes) & "')"
                  Else
                        Conn.Execute "Insert Into tblForm3_Footnotes (GroupCode, Counter, Footnote) Values (" & Session("GroupCode") & ", " & rsCounter.fields("MaxCounter").value+1 & ", '" & sqlBless(Notes) & "')"
                  End IF
                  rsCounter.Close
                  Set rsCounter=nothing                  
            End If
            Notes=""
            txtEditHidden=""
      End If
End If%>

<%IF Request("EditFootnote") = "Edit Footnote" THEN      
      If Request("OptionID")<>"" then
            SET rsEdit = Server.CreateObject("ADODB.Recordset")
            rsEdit.Open "Select Footnote from tblForm3_Footnotes Where ID=" & CInt(Request("OptionID")), Conn, 0
            If rsEdit.EOF=True Then
                  Notes=""
            Else
                  Notes=CheckNull(rsEdit.fields("Footnote").value)
            End IF
            txtEditHidden="Edit"
      End if
End IF%>


<%IF Request("DeleteFootnote") = "Delete Footnote" THEN      
      If Request("OptionID")<>"" then
            Conn.Execute "DELETE FROM tblForm3_Footnotes WHERE ID IN (" & Request("OptionID") & ")"
      end if
End IF%>


<body onLoad="document.forms[0].Notes.value=opener.document.forms[0].<%=Request.QueryString("txtname")%>.value">
<form name="popForm" Action="Footnotes.asp" method="post">

<input type="Hidden" name="txtEditHidden" value="<%=Server.HTMLEncode( txtEditHidden )%>">

<input type="Hidden" name="txtname1" value="<%=Server.HTMLEncode( txtname1 )%>">
<input type="Hidden" name="txtname2" value="<%=Server.HTMLEncode( txtname2 )%>">
<input type="Hidden" name="txtname3" value="<%=Server.HTMLEncode( txtname3 )%>">
<input type="Hidden" name="txtname4" value="<%=Server.HTMLEncode( txtname4 )%>">

<table width="100%" border="1" bordercolor="Black">
      <tr>
            <td width="6%">&nbsp;</td>
            <td width="6%" align="center">&nbsp;</td>
            <td width="88%" align="center"><b>Footnotes</b></td>
      </tr>
<%Set rs=server.createobject("ADODB.Recordset")%>
<%rs.open "Select * from tblForm3_Footnotes Where GroupCode=" & Session("GroupCode"),conn,3
if rs.eof and rs.bof then%>
      
<%else%>            

<%i=0%>

<%while not rs.eof%>
<tr>            
      <td width="6%"><b><font color="Blue" size="-1">&nbsp;<INPUT TYPE="RADIO" <%if Cint(Request("OptionID")) = rs("ID") Then Response.Write ("CHECKED") : Response.Write("")%> NAME="OptionID" value="<%Response.write rs("ID")%>"></font></b></td>
      <td width="6%" align="center"><b><font color="Blue" size="-1">&nbsp;<%=CheckNull(rs.fields("Counter").value)%></font></b></td>
      <td width="88%" align="center"><b><font color="Blue" size="-1">&nbsp;<%=CheckNull(rs.fields("Footnote").value)%></font></a></td>
</tr>
<%
            i=i+1
            rs.movenext
      wend
%>

<%end if%>
<%rs.close:set rs=nothing%>
</table>

<br><br><br>
<table>
<tr>
      <td>
            <textarea rows="8" name="Notes" cols="50"><%=Server.HTMLEncode( Notes )%></textarea><br>
      </td>
      <td>
            <table width="100%" border="1" bordercolor="Black">
                  <tr>
                        <td align="center" colspan="2">
                        <b>Apply Footnote to these Table 1 fields:</b><br>
                        </td>
                  </tr>
                  <tr>
                        <td>
                              &nbsp;&nbsp;1. Title of Security:&nbsp;&nbsp;<br>
                        </td>
                        <td>
                              <INPUT TYPE="checkbox" NAME="TitleSecurity" <%if Ucase(TitleSecurity) = "ON" OR Ucase(TitleSecurity) = "TRUE" Then Response.Write ("CHECKED") : Response.Write("")%>>
                        </td>
                  <tr>
                  </tr>
                        <td>
                              &nbsp;&nbsp;2. Amount of Securities Beneficially Owned:&nbsp;&nbsp;
                        </td>
                        <td>
                              <INPUT TYPE="checkbox" NAME="AmtSecOwned" <%if Ucase(AmtSecOwned) = "ON" OR Ucase(AmtSecOwned) = "TRUE" Then Response.Write ("CHECKED") : Response.Write("")%>>
                        </td>
                  </tr>
                  <tr>
                        <td>
                              &nbsp;&nbsp;3. Ownership Form: Direct (D) or Indirect (I):&nbsp;&nbsp;
                        </td>
                        <td>
                              <INPUT TYPE="checkbox" NAME="OwnerForm" <%if Ucase(OwnerForm) = "ON" OR Ucase(OwnerForm) = "TRUE" Then Response.Write ("CHECKED") : Response.Write("")%>>
                        </td>
                  </tr>
                  <tr>
                        <td>
                              &nbsp;&nbsp;4. Nature of Indirect Beneficial Ownership:&nbsp;&nbsp;
                        </td>
                        <td>
                              <INPUT TYPE="checkbox" NAME="NatureIndirect" <%if Ucase(NatureIndirect) = "ON" OR Ucase(NatureIndirect) = "TRUE" Then Response.Write ("CHECKED") : Response.Write("")%>>
                        </td>
                  </tr>
            </table>
      </td>
</tr>
<tr>
      <td colspan="2">
            <hr width="100%" color="Black">
      </td>
</tr>
<tr>
      <td colspan="2">
            <table width="100%">
                  <tr>
                        <td  align="center">
                              <input type="submit" name="AddFootnote" value="Add Footnote" onclick="Getvalue()">
                        </td>
                        <td  align="center">
                              <input type="submit" name="EditFootnote" value="Edit Footnote">
                        </td>
                        <td  align="center">
                              <input type="submit" name="DeleteFootnote" value="Delete Footnote">
                        </td>
                  </tr>
            </table>
      </td>
</tr>

</table>
</form>

</body>
</html>
Avatar of archrajan
archrajan

Can u post ur view source?
that wud be easy for debugging
I may be missing something here, but is there any need for your AddFootnote button to submit the page to the server.

If there isn't then you can simply use a button input (type="button" rather than type="submit"). This will respond to onclick events but won't submit the page to the server.
Avatar of grishat

ASKER

Yes I do. I have to populate the top portion of the screen with all the footnotes submitted. I also must be able to delete and edit any footnote by clicking on the option box next to it.
can u post ur view source from the browser...
the generated code will be easier to debug
Avatar of grishat

ASKER

Basicaly the question is how do I keep the Opener.Document.FormName value after the popup window is being refreshed.
Avatar of grishat

ASKER

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">


T1_1_FootNoteID_2
<html>
<head>
      <title>Foot Notes</title>
      
<SCRIPT LANGUAGE="JavaScript">

function Getvalue()
{
opener.document.Form3Edit.T1_1_FootNoteID_2.value=document.popForm.Notes.value
opener.document.Form3Edit.T1_2_FootNoteID_2.value=document.popForm.Notes.value
opener.document.Form3Edit.T1_3_FootNoteID_2.value=document.popForm.Notes.value
opener.document.Form3Edit.T1_4_FootNoteID_2.value=document.popForm.Notes.value
}
</script>

</head>



<body onLoad="document.forms[0].Notes.value=opener.document.forms[0]..value">
<form name="popForm" Action="Footnotes.asp" method="post">

<input type="Hidden" name="txtEditHidden" value="">

<input type="Hidden" name="txtname1" value="T1_1_FootNoteID_2">
<input type="Hidden" name="txtname2" value="T1_2_FootNoteID_2">
<input type="Hidden" name="txtname3" value="T1_3_FootNoteID_2">
<input type="Hidden" name="txtname4" value="T1_4_FootNoteID_2">

<table width="100%" border="1" bordercolor="Black">
      <tr>
            <td width="6%">&nbsp;</td>
            <td width="6%" align="center">&nbsp;</td>
            <td width="88%" align="center"><b>Footnotes</b></td>
      </tr>

<tr>            
      <td width="6%"><b><font color="Blue" size="-1">&nbsp;<INPUT TYPE="RADIO"  NAME="OptionID" value="21"></font></b></td>
      <td width="6%" align="center"><b><font color="Blue" size="-1">&nbsp;1</font></b></td>
      <td width="88%" align="center"><b><font color="Blue" size="-1">&nbsp;lllllllllllllllllllllllll</font></a></td>
</tr>

<tr>            
      <td width="6%"><b><font color="Blue" size="-1">&nbsp;<INPUT TYPE="RADIO"  NAME="OptionID" value="122"></font></b></td>
      <td width="6%" align="center"><b><font color="Blue" size="-1">&nbsp;2</font></b></td>
      <td width="88%" align="center"><b><font color="Blue" size="-1">&nbsp;fghfgh</font></a></td>
</tr>

</table>

<br><br><br>
<table>
<tr>
      <td>
            <textarea rows="8" name="Notes" cols="50"></textarea><br>
      </td>
      <td>
            <table width="100%" border="1" bordercolor="Black">
                  <tr>
                        <td align="center" colspan="2">
                        <b>Apply Footnote to these Table 1 fields:</b><br>
                        </td>
                  </tr>
                  <tr>
                        <td>
                              &nbsp;&nbsp;1. Title of Security:&nbsp;&nbsp;<br>
                        </td>
                        <td>
                              <INPUT TYPE="checkbox" NAME="TitleSecurity" >
                        </td>
                  <tr>
                  </tr>
                        <td>
                              &nbsp;&nbsp;2. Amount of Securities Beneficially Owned:&nbsp;&nbsp;
                        </td>
                        <td>
                              <INPUT TYPE="checkbox" NAME="AmtSecOwned" >
                        </td>
                  </tr>
                  <tr>
                        <td>
                              &nbsp;&nbsp;3. Ownership Form: Direct (D) or Indirect (I):&nbsp;&nbsp;
                        </td>
                        <td>
                              <INPUT TYPE="checkbox" NAME="OwnerForm" >
                        </td>
                  </tr>
                  <tr>
                        <td>
                              &nbsp;&nbsp;4. Nature of Indirect Beneficial Ownership:&nbsp;&nbsp;
                        </td>
                        <td>
                              <INPUT TYPE="checkbox" NAME="NatureIndirect" >
                        </td>
                  </tr>
            </table>
      </td>
</tr>
<tr>
      <td colspan="2">
            <hr width="100%" color="Black">
      </td>
</tr>
<tr>
      <td colspan="2">
            <table width="100%">
                  <tr>
                        <td  align="center">
                              <input type="submit" name="AddFootnote" value="Add Footnote" onclick="Getvalue()">
                        </td>
                        <td  align="center">
                              <input type="submit" name="EditFootnote" value="Edit Footnote">
                        </td>
                        <td  align="center">
                              <input type="submit" name="DeleteFootnote" value="Delete Footnote">
                        </td>
                  </tr>
            </table>
      </td>
</tr>
<tr>
      <td colspan="2">
            <hr width="100%" color="Black">
      </td>
</tr>
<tr>
      <td colspan="2" align="center">
      <br><br><br>
            <input type="button" value="Close Window" onclick="self.close();">
      </td>
</tr>
</table>
</form>

</body>
</html>
u can use cookies to do it.
but before that am not understanding this function

function Getvalue()
{
opener.document.Form3Edit.T1_1_FootNoteID_2.value=document.popForm.Notes.value
opener.document.Form3Edit.T1_2_FootNoteID_2.value=document.popForm.Notes.value
opener.document.Form3Edit.T1_3_FootNoteID_2.value=document.popForm.Notes.value
opener.document.Form3Edit.T1_4_FootNoteID_2.value=document.popForm.Notes.value
}


do u realize that the last statement only will be executed as document.popForm.Notes.value is being overwritten
in all ur statements??
(I didn't read the code involved but I can answer your question about why the parent. value is no longer accurate)

the reason why a refresh of the popup isn't catching the parent value is that when you change src on a popup it gets orphaned.
the identity is no longer maintained as a security measure.  

1.  Cookies can keep it working.

2.  You could use a frame within the popup and only switch the frame's contents... thus keeping the parent-popup relationship
Avatar of grishat

ASKER

No, it's being assigned to 4 different textboxes (1-4). Could you please show me how to assign the value to a cookie and use it in the this function. Thanks.
Avatar of grishat

ASKER

I'm sorry I'm not familiar with how to use frames. I'm relatively new to this.
ahh, no worries, we were all new once.  it might take a while to explain all of the ideas involved.

does it makes sense why letting a popup always see a value on the parent window is a possible security risk?
Avatar of grishat

ASKER

It makes sense, but how else do I communicate with the parent form after refreshing the popup form. The reason I refresh the popup window is because when the Add Footnote button is clicked, I save the footnote in the Database and then display it and all other footnotes from DB in the top portion of the screen. I also have to assign a value back to the parent form's hidden boxes.
Avatar of grishat

ASKER

Can somebody please shop me how to assign the Opener.Document.FormName to a cookie?
ASKER CERTIFIED SOLUTION
Avatar of archrajan
archrajan

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
No comment has been added to this question in more than 21 days, so it is now classified as abandoned..
I will leave the following recommendation for this question in the Cleanup topic area:

Accept: archrajan

Any objections should be posted here in the next 4 days. After that time, the question will be closed.

cem_turk

EE Cleanup Volunteer