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.

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

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.

Airshow

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.