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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hidden Form Field Problem

Status
Not open for further replies.

zwarte

Programmer
Jul 5, 2002
9
BR
Check this out. I have two test files. One called parent.html and the other called child.html. What the files do is open a pop-up window called child from parent. You can then plug some data into child, hit "send info" and the data the hidden form field should be populated. It's not working however. Here are the files

parent.html

Code:
<html>
  <head>
    <title>Test</title>
    <script type="text/javascript">
      function OpenWindow(){
        var winPop = window.open("child.html","winPop");
      }
    </script>
  </head>
  <body>
    <form name="form1">
      <input type="hidden" name="text1" value="" id="text">
      <input type="button" name="button" value="Grab Info"  

onclick="OpenWindow()">
    </form>
  </body>
</html>

Here is the child:

Code:
<html>
  <head>
    <title>Test</title>
    <script type="text/javascript">
      function SendInfo(){
        var txtVal = document.formPop.textPop.value;
        window.opener.document.form1.text1.value = txtVal;
        window.close();
      }
    </script>
  </head>
  <body>
    <form name="formPop">
      <input type="text" name="textPop">
      <input type="button" name="button" value="Send Info"  

onclick="SendInfo()">
    </form>
  </body>
</html>

If i switch the input type to text it picks up the data. If I set it to hidden, it omits it. Any suggestions?
 
I just tested it again, it doesn't work.

1) I go to the parent.html file and click "grab info" the child.html file pops up and i plug in a number. Something random like 121212. When I hit send info, it hould post that info back into the hidden field. When I do a view source, the value should hold 121212 but instead it holds "". Does it do that for you?

-Zwarte
 
It doesn't work like that. your source code will not be altered but the value will be set.

If you want to test the hidden field somehow for assurance then do a alert or something to show it to you in the child

like this

function SendInfo(){
var txtVal = document.formPop.textPop.value;
window.opener.document.form1.text1.value = txtVal;
alert(opener.form1.text1.value);
window.close();
}

or put a button on the parent

<form name="form1">
<input type="hidden" name="text1" value="" id="text">
<input type="button" name="button" value="Grab Info" onclick="OpenWindow();">
<input type="button" name="test" value="test" onclick="alert(document.form1.text1.value);">
</form>

____________ signature below ______________
You may get help by means of code here. Just recall what happens to a rat when he eats the cheese off a rat trap while you're Ctrl+C/Ctrl+V'ing that code as your own

 
Just as I figured. Thanks for your help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top