I am passing a value through query string to a popup and then trying to pass it back to the main page... I store the value in a hidden input box

<input type="text" name="FromZip" id="FromZip" value="<% response.write(Request.QueryString("txtZipFr")) %>" />

and am passing it back through query string to the main page with

<script language="JavaScript" type="text/javascript">
   //<!--
    //opener.location.reload(true);
   //window.opener.location='bl_zip_sngl.asp?
   var x;
   x = document.getElementsByName("FromZip").value;
   alert(x);
    window.opener.location='bl_zip_sngl.asp?txtZipFr='  +x
    self.close();
  // -->
</script>

It gives me undefined as the output, but when I do it like this

<script language="JavaScript" type="text/javascript">
   //<!--
    //opener.location.reload(true);
   //window.opener.location='bl_zip_sngl.asp?
   var x;
   document.getElementsByName("FromZip").value = 79797; //Only difference
   x = document.getElementsByName("FromZip").value;
   alert(x);
    window.opener.location='bl_zip_sngl.asp?txtZipFr='  +x
    self.close();
  // -->
</script>

it at least returns a real value. Unfortunately I need to dynamically populate the box with what the user originally typed in.

document.getElementsByName() returns a nodeList or simply put an array. You just can't directly assign a value to an array reference. You need to do something like the one given below assuming there is only element which goes by the name of 'FromZip'. document.getElementsByName("FromZip")[0].value = 79797;

Edited 3 Years Ago by happygeek: fixed formatting

For me that not work try on this website maybe will help you.

Edited 6 Years Ago by Ezzaral: Snipped unrelated url.

This article has been dead for over six months. Start a new discussion instead.