| | |
getElementsByName() generates undefined ouput value in a textbox
Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
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
and am passing it back through query string to the main page with
It gives me undefined as the output, but when I do it like this
it at least returns a real value. Unfortunately I need to dynamically populate the box with what the user originally typed in.
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
<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
javascript Syntax (Toggle Plain Text)
<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
javascript Syntax (Toggle Plain Text)
<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>
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; Last edited by ~s.o.s~; Sep 5th, 2007 at 12:35 pm.
I don't accept change; I don't deserve to live.
•
•
Join Date: Dec 2004
Posts: 19
Reputation:
Solved Threads: 0
For me that not work try on this website maybe will help you
![]() |
Similar Threads
- Dev C++ linker errors, undefined reference (C++)
- Dev-C++, GLUI linker error, undefined reference (C++)
- Printing a textbox? (C#)
- undefined reference errors when using C++ Sockets Library (C++)
- object undefined instead of string literal (JavaScript / DHTML / AJAX)
- TextBox - how to determine focus (ASP.NET)
- Can't update a textbox in Visual C++ (C++)
- Undefined variable: PHP_SELF (PHP)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: set image path onMouseClick
- Next Thread: How to rename/hide the title of the popup window
| Thread Tools | Search this Thread |
acid2 ajax ajaxcode ajaxhelp animate array automatically beta box bug calendar cart checkbox child codes column createrange() css cursor date debugger decimal design disablefirebug dom download dropdown editor element engine enter error explorer ext file firefox focus forms frameworks getselection google gwt html htmlform ie8 iframe images index internet java javascript jawascriptruntimeerror jquery jsf jsfile jsp jump listbox maps masterpage math menu microsoft mimic mp4 object onmouseoutdivproblem onmouseover onreadystatechange parent pdf php player post problem programming progressbar prototype redirect regex runtime safari scale scriptlets scroll search select shopping size sql text textarea w3c web website window windowofwords windowsxp wysiwyg \n






