#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2009
    Posts
    30
    Rep Power
    5

    Passing value from one page textbox to another page textbox


    Hi,
    I've two pages(forms), page2 pops up when we click on page1 form button A or B. On page 2, user can only fills out the TextBox 1 or TextBox 2.

    After submitting the Page2 Form, I want to pass the value of Page2 Textbox 1 or 2 to populate on Page1 Textbox A or B(if user click on Button A, value should go to Page1, TextBox A).

    Code of page 1

    Code:
    <script type="text/javascript">
    
    function open_window() {
    window.open('page2.htm','','width=600,height=200,toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,copyhistory=yes,resizable=yes');
    }
    
    
    
    </script>
    
    <form>
    <table width="1023" align="center">
      <tr>
        <td colspan="2" bgcolor="#E9E9E9">TextBox A</td>
        <td bgcolor="#E9E9E9">TextBox B</td>
      </tr>
      <tr>
        <td colspan="2" bgcolor="#E9E9E9">A.
          <input type="text" name="Page1_TxtA" id="Page1_TxtA" value="" size="20" maxlength="40" ></td>
            <td bgcolor="#E9E9E9">
          <input type="button" name="Page1_BtnA" value="Button A" onClick="open_window()"/>
        </td>
      </tr>
      <tr>
        <td colspan="2" bgcolor="#E9E9E9">B.
          <cfinput type="text" name="Page1_TxtB" id="Page1_TxtB" value="" size="20" maxlength="40" ></td>
            <td bgcolor="#E9E9E9">
          <input type="button" name="Page1_BtnB" value="Button B" onClick="open_window()"/>
        </td>
      </tr>
    </table>
    
    </form>
    Page 2 code is here:

    Code:
    <script type="text/javascript">
    
    function close_window() {
    window.close();
    }
    
    
    
    </script>
    
    
    <form name="form1">
    
    
    <table width="576" border="1">
      <tr>
        <td width="273">TEXTBOX 1</td>
        <td width="485">TEXTBOX 2</td>
      </tr>
      <tr>
        <td><input type="text" name="Page2_Txt1"  id="Page2_Txt1" /></td>
        <td><input type="text" name="Page2_Txt2" id="Page2_Txt2" /></td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td><input TYPE="BUTTON" name="npage" VALUE="Display" onClick="close_window();"></td>
      </tr>
    </table>
    
    
    </form>
    any help, comment or suggestion regarding this problem, would be deeply appreciated.
  2. #2
  3. No Profile Picture
    http://stealthwd.ca
    Devshed Novice (500 - 999 posts)

    Join Date
    Dec 2005
    Posts
    688
    Rep Power
    200
    You can pass values back to the parent window with window.opener...

    so you can do something like window.opener.document.getElementById("parentInput").value = document.getElementById("popUpInput").value


    For text boxes I believe you might need .innerHTML instead of .value

    does this help?
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2009
    Posts
    30
    Rep Power
    5
    You are right, that's all it needs. Thanks for your help, you really are a life saver....

IMN logo majestic logo threadwatch logo seochat tools logo