0

Hello,

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.

2
Contributors
3
Replies
4
Views
6 Years
Discussion Span
Last Post by Airshow
0

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

Airshow

Edited by Airshow: n/a

0

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...

0

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.

Airshow

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.