Problem with "document.getElementById()"
-
Hi, I am having a problem in javascript, im trying to implement autocomplete on a textbox named "txtAddress". i found a JS file from net which does all processing of autocomplete using AJAX. following code in my script tag gives error: var txt=document.getElementById("txtAddress").value; or var txt=document.getElementById("txtAddress").text; I get the error document.getElementById(txtid) has no properties When I try var txt=document.getElementById("txtAddress"); txt gets the null value. I am new to javascript and dont know much about it, kindly tell me what i am missing here. Thanks in advance... Regards, Affan Ahmad Toor
.................. QUAIDIAN FOR ONCE, QUAIDIAN FOR EVER!
-
Hi, I am having a problem in javascript, im trying to implement autocomplete on a textbox named "txtAddress". i found a JS file from net which does all processing of autocomplete using AJAX. following code in my script tag gives error: var txt=document.getElementById("txtAddress").value; or var txt=document.getElementById("txtAddress").text; I get the error document.getElementById(txtid) has no properties When I try var txt=document.getElementById("txtAddress"); txt gets the null value. I am new to javascript and dont know much about it, kindly tell me what i am missing here. Thanks in advance... Regards, Affan Ahmad Toor
.................. QUAIDIAN FOR ONCE, QUAIDIAN FOR EVER!
You're missing the bit where you need a text input with an Id of txtAddress. It doesn't exist, and so the code won't work.
Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
-
You're missing the bit where you need a text input with an Id of txtAddress. It doesn't exist, and so the code won't work.
Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
Thanks for reply... i checked the textbox, its 'id' & 'name' properties exists but im not sure whether it has initialized/loaded when this code executes. how can i ensure this? Regards, Affan Ahmad Toor
.................. QUAIDIAN FOR ONCE, QUAIDIAN FOR EVER!
-
Thanks for reply... i checked the textbox, its 'id' & 'name' properties exists but im not sure whether it has initialized/loaded when this code executes. how can i ensure this? Regards, Affan Ahmad Toor
.................. QUAIDIAN FOR ONCE, QUAIDIAN FOR EVER!
View the source of the page itself. For example, if this is an ASP.NET server control, the Id is autogenerated for the client side and is not what you see in your code.
Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
-
Hi, I am having a problem in javascript, im trying to implement autocomplete on a textbox named "txtAddress". i found a JS file from net which does all processing of autocomplete using AJAX. following code in my script tag gives error: var txt=document.getElementById("txtAddress").value; or var txt=document.getElementById("txtAddress").text; I get the error document.getElementById(txtid) has no properties When I try var txt=document.getElementById("txtAddress"); txt gets the null value. I am new to javascript and dont know much about it, kindly tell me what i am missing here. Thanks in advance... Regards, Affan Ahmad Toor
.................. QUAIDIAN FOR ONCE, QUAIDIAN FOR EVER!
It's about parentesis more than likely - try the following:
var txt=(document.getElementById("txtAddress")).value;
"Knock me down, I'll get straight back up again, I'll come back stronger than a powered up pacman" (Lilly Allen / Kaiser Chiefs) -
It's about parentesis more than likely - try the following:
var txt=(document.getElementById("txtAddress")).value;
"Knock me down, I'll get straight back up again, I'll come back stronger than a powered up pacman" (Lilly Allen / Kaiser Chiefs)RichardGrimmer wrote:
It's about parentesis more than likely - try the following: var txt=(document.getElementById("txtAddress")).value;
Actually very much less than likely. The extra parentheses are completely superflous.
--- single minded; short sighted; long gone;
-
RichardGrimmer wrote:
It's about parentesis more than likely - try the following: var txt=(document.getElementById("txtAddress")).value;
Actually very much less than likely. The extra parentheses are completely superflous.
--- single minded; short sighted; long gone;
Ah well - you live and learn :)
"Knock me down, I'll get straight back up again, I'll come back stronger than a powered up pacman" (Lilly Allen / Kaiser Chiefs)
-
It's about parentesis more than likely - try the following:
var txt=(document.getElementById("txtAddress")).value;
"Knock me down, I'll get straight back up again, I'll come back stronger than a powered up pacman" (Lilly Allen / Kaiser Chiefs)