Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing text box content

Status
Not open for further replies.

barrykellett

Programmer
Mar 4, 2003
29
GB
I have an email page and a seperate page for choosing email addresses for the email. How can I click a button on the addresses page that will take the items in a text box in it and transfer them into the address bar on my main email window, closing the addresses window in the process?
 
client side coding would be the best was to do it.

I use this type of method for a calendar pop up in some of my programs here is the code:

main page apsx w/ javascript
Code:
<head>
  <script language=javascript>
    //open pop up windows
    function NewWindow( link, h, w, resize, scroll, tool, loc, dir, status, menu ){
    var centerWidth=(screen.width / 2) - (w / 2);
    var centerHeight=(screen.height / 2) - (h / 2);

    window.open(link, "PopUp", "height=" + h + ", width=" + w + ", top=" + centerHeight + ", left=" + centerWidth + ", resizable=" + resize + ", scrollbars=" + scroll + ", toolbar=" + tool + ", location=" + loc + ", directories=" + dir + ", status=" + status + ", menubar=" + menu);
}
  </script>
<head>
<body>
  <form id="Form1" method="post" runat="server">
    <asp:HyperLink id="lnkDate" runat="server" NavigateUrl="javascript: NewWindow('calendar.aspx?frm=Form1&amp;obj=txtDate', 200, 250, 0, 0, 0, 0, 0, 0, 0);">Date</asp:HyperLink>
    <asp:textbox id="txtDate" runat="server"></asp:textbox>
  </form>
</body>
Calendar Page aspx w/ javascript and code
Code:
<HEAD>
  <script language="javascript">
  //Return value from pop up window to main window
  function ReturnDate( D, frm, obj ){
    if ( D != "" ){
      window.opener.<%=Request("frm")%>.<%=Request("obj")%>.value= D;
      window.opener.<%=Request("frm")%>.<%=Request("obj")%>.focus();
      window.close();
    }
  }
  </script>
</HEAD>
<body onload="ReturnDate( document.Form1.txtDate.value );">
  <form id="Form1" method="post" runat="server">
    <asp:Calendar id="calDate" runat="server"></asp:Calendar>
    <INPUT id="txtDate" type="hidden" runat="server">
  </form>
</body>

Private Sub calDate_SelectionChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles calDate.SelectionChanged
  If calDate.SelectedDates.Count = 1 Then
    txtDate.Value = calDate.SelectedDate.ToShortDateString
  End If
End Sub

You would need to modify the pop up window to have javascript append emails to the hidden input box, but the passing of info to and from the main page would be very similar

Jason Meckley
Database Analyst
WITF
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top