How to get textbox value
My textbox ID is TextBox1, How to get its value?
var mytext = document.getElementById("TextBox1");
var mytext = document.getElementById("TextBox1").value;
I think you just helped me figure out my problem!
I'm not sure, but I think the variable has to be the same as the id:
var TextBox1 = document.getElementById("TextBox1").value;
I could be wrong about that. Also, what I have seen is single quotes, not double so try:
var TextBox1 = document.getElementById('TextBox1').value;
Not sure if that makes a difference or not either.
I'm gonna try changing my var names now to see if it works!
Don't execute the code until the element is rendered.
Use the error console.
If it still doesn't work, post your entire code including HTML.
It certainly does not have to be the same. In fact if (for whatever reason) you're using a global variable, it should not match the ID of any element, due to IDs being treated in some cases as global variables.
Originally Posted by dubmecrazy
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)