473,667 Members | 2,557 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

getElementsByNa me() generates undefined ouput value in a textbox

rrocket
116 New Member
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
Expand|Select|Wrap|Line Numbers
  1. <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
Expand|Select|Wrap|Line Numbers
  1. <script language="JavaScript" type="text/javascript">
  2.    //<!--
  3.     //opener.location.reload(true);
  4.    //window.opener.location='bl_zip_sngl.asp?
  5.    var x;
  6.    x = document.getElementsByName("FromZip").value;
  7.    alert(x);
  8.     window.opener.location='bl_zip_sngl.asp?txtZipFr='+x
  9.     self.close();
  10.   // -->
  11. </script>
It gives me undefined as the output, but when I do it like this
Expand|Select|Wrap|Line Numbers
  1. <script language="JavaScript" type="text/javascript">
  2.    //<!--
  3.     //opener.location.reload(true);
  4.    //window.opener.location='bl_zip_sngl.asp?
  5.    var x;
  6.    document.getElementsByName("FromZip").value = 79797; //Only difference
  7.    x = document.getElementsByName("FromZip").value;
  8.    alert(x);
  9.     window.opener.location='bl_zip_sngl.asp?txtZipFr='+x
  10.     self.close();
  11.   // -->
  12. </script>
it at least returns a real value. Unfortunately I need to dynamically populate the box with what the user originally typed in.
Sep 4 '07 #1
14 8141
pbmods
5,821 Recognized Expert Expert
Changed thread title to better describe the problem (did you know that threads whose titles do not follow the Posting Guidelines actually get FEWER responses?).
Sep 4 '07 #2
Logician
210 New Member
x = document.getEle mentsByName("Fr omZip").value;
Try reading:
Expand|Select|Wrap|Line Numbers
  1. document.getElementsByName("FromZip")[0].value;
Otherwise you'll need to show the document.
Sep 4 '07 #3
rrocket
116 New Member
I tried that, but it gave me a null or not an object error...
Sep 4 '07 #4
gits
5,390 Recognized Expert Moderator Expert
hi ...

when do you call the js? for all dom-methods the dom has to be read for use with js ... so to be sure you should do everything with the dom after the onload of the doc (body's onload) ... at this point the browser has loaded the docs-dom and you may use it reliably ...

kind regards
Sep 4 '07 #5
rrocket
116 New Member
The javascript is called in the last statement just before everything is sent back to the main window... I am not sure that is what you are asking or not. I am mainly trying to pull just the values in the hidden text boxes. I know they are coming up since I have the input boxes set to text instead of hidden at the moment.

I can send the entire page if you think that will help.
Sep 4 '07 #6
gits
5,390 Recognized Expert Moderator Expert
it would help ... ;) ... but for simplicity ... and to simplify the problem for yourself you should try to create an example that contains the relevant things you have problems with ... during this simple step you might find out the problem for yourself and you will learn with every step you take in that direction ... i promise ... but you may also post the full code in case it is not TOO much ;))

kind regards

ps: try posts #3 solution again ... i think it should work ...
Sep 4 '07 #7
rrocket
116 New Member
I pull most of the stuff that does not have anything to do with the issue... I can alway cut more out if needed.

Expand|Select|Wrap|Line Numbers
  1. <%
  2.     IF (request.Form("op") <> 1) THEN         
  3. %>
  4.  
  5. <html xmlns="http://www.w3.org/1999/xhtml">
  6.     <head>
  7.         <title>Add A Description</title>
  8.             </head>
  9.     <body>
  10.  
  11.         <form action="AddNewDescription.asp" method="post" onsubmit="return validate_form()" name="newDescription">
  12.         <!--<form action="BL_ZIP_SNGL.asp" method="post" onsubmit="return validate_form()" name="BL_Zip_Sngl">-->
  13.             <table cellpadding="1" cellspacing="0" bgcolor="#000000" width="250">
  14.                 <tr>
  15.                     <td>
  16.                         <table width="100%" cellpadding="5" cellspacing="0" bgcolor="#FFFFFF">
  17.                             <tr bgcolor="#AC0636">
  18.                                 <td colspan="2" style="height: 15px"><span style="font-size: 9pt; font-family: @Arial Unicode MS; color: #ffffff;"><strong>
  19.                                         Add a description</strong></span></td>
  20.                             </tr>
  21.                             <tr bgcolor="#FFFFFF" style="color: #000000">
  22.                                 <td>
  23.                                     <strong><span style="font-size: 10pt; font-family: @Arial Unicode MS">Description:</span></strong></td>
  24.                                 <td style="text-align: right"><input type="text" name="description"/></td>
  25.                             </tr>
  26.                             <tr style="color: #000000">
  27.                                 <td>
  28.                                     <span style="font-size: 10pt; font-family: @Arial Unicode MS"><strong>NMFC #:</strong></span>
  29.                                  </td>
  30.                                 <td style="text-align: right"><input type="text" name="nmfc"/></td>
  31.                             </tr>
  32.                             <tr>  
  33.                                 <td width="100%" colspan="2" valign="top"><font size="2">If you need help with your NMFC # please call 1-866-633-8236</font></TD>                
  34.                             </TR>
  35.                             <tr bgcolor="#CCCCCC" style="color: #000000">
  36.                                 <td colspan="2" style="text-align: right"><input type="submit" value="Submit" /></td>
  37.                             </tr>
  38.                         </table>
  39.                     </td>
  40.                 </tr>
  41.             </table>
  42.             <div>zipfr:<%response.write(Request.QueryString("txtZipFr"))%></div>
  43.              <div>zipto:<%response.write(Request.QueryString("txtZipTo"))%></div>
  44.              <input type="text" name="FromZip" id="FromZip" value="<%response.write(Request.QueryString("txtZipFr"))%>" />
  45.              <input type="text" name="ToZip" id="ToZip" value="<%response.write(Request.QueryString("txtZipTo"))%>" />
  46.             <input type="hidden" name="op" value="1" />
  47.             <input type="hidden" name="id" value="<% response.write(Request.QueryString("id")) %>" />
  48.  
  49.         </form>
  50.     </body>
  51. </html>
  52. <%
  53.     ELSE
  54.         DescAdd()
  55. %>
  56. <script language="JavaScript" type="text/javascript">
  57.    //<!--
  58.     //opener.location.reload(true);
  59.    //window.opener.location='bl_zip_sngl.asp'
  60.    //var x = 0;
  61.    //document.getElementsByName('FromZip').value = 79797;
  62.    vFromZip = document.getElementsByName("FromZip").value;
  63.    vToZip = document.getElementsByName("ToZip").value;
  64.    alert(vToZip);
  65.     window.opener.location='bl_zip_sngl.asp?txtZipFr='+ vFromZip + '&txtZipTo=' + vToZip;
  66.     self.close();
  67.   // -->
  68. </script>
  69. <%
  70.     END IF
  71. %>
  72.  
  73.  
Sep 4 '07 #8
pbmods
5,821 Recognized Expert Expert
Heya, Rocket.

Try post #3's solution.

document.getEle mentsByName() has "Elements" [plural] in it, which would imply that it is returning multiple Elements.
Sep 4 '07 #9
gits
5,390 Recognized Expert Moderator Expert
hi ...

as i said ... try posts #3 solution again:

Expand|Select|Wrap|Line Numbers
  1. document.getElementsByName('whatever_name');
returns a collection (list) of elements ... so

Expand|Select|Wrap|Line Numbers
  1. document.getElementsByName('whatever_name')[0].value;
returns the value of the first node with the given name ...

kind regards
Sep 4 '07 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

1
3106
by: Pavils Jurjans | last post by:
Hello, I am building custom hashtable class, and thinking about value retrieval issues. The thing is, that sometimes the hashtable value may contain value null. If someone is reading this value like this value = myHashtable; then, is the value of "myKey" key is null, then the result is the same, as
3
13719
by: VB Programmer | last post by:
In my ASPX page how do I get the .text value of a textbox that is in the ItemTemplate of a datalist (using HTML)? The textbox contains the quantity for a shopping cart item. The textbox is called "txtQty" and the current HTML is this (I need to replace xxxx with the text value from the textbox): <A href='UpdateCart.aspx?CartId=<%# DataBinder.Eval(Container.DataItem, "CartID") %>&Qty=xxxx'><IMG src="Resources/UpdateBtn.jpg"...
49
14477
by: matty | last post by:
Hi, I recently got very confused (well that's my life) about the "undefined" value. I looked in the FAQ and didn't see anything about it. On http://www.webreference.com/programming/javascript/gr/column9/ they say: <snip> The undefined property A relatively recent addition to JavaScript is the undefined property.
0
8457
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8788
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8563
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6203
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5675
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4200
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4372
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2776
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2013
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.