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.

Recommended Answers

All 2 Replies

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;

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.