I'm trying to access a value from an input form. I know this works without the onkeyup event but with it it says the that document.formname.elementid.value is undefined! Its extremely frustrating. As the user types into the input, I am using AJAX to generate some more options which works but I need to be able to access the input type=text value. Here is my code:

<input type=text id= IDNAME onkeyup=functionname('/somephpfile.php?IDNAMEASVAR=',this.value) />

thanks in advance.

Make sure the form and the input field both have unique names (typically identical to their ids) then try document.forms["formname"].elementName.value .


Thanks for the reply. Yes I did check that but unfortunately could not find anything amiss. I got around this by storing it in a global javascript variable. As there was another function that could access that variable...

By passing this , it and all of its properties become available to the function, including .value , .type and even .form .

<input type="text" id="IDNAME" onkeyup="functionname('/somephpfile.php?IDNAMEASVAR=', this)" />

In any case, a global variable should not be necessary.