Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

javascript: assign textbox value to variable

I have a javascript function where I assign the value of a textbox to a variable.
I have no problem in IE 4 but Nescape 4.x says there is a javascript error.

The line is:

my_parm = thisForm.txtNDC.value;

But if I place the literal like this, it works:

my_parm = "7007";

What am I doing wrong?
[341 byte] By [Jeff] at [2007-11-9 15:35:11]
# 1 Re: javascript: assign textbox value to variable
It makes a different where in the page your trying to assign that variable
in relation to where the form itself is (on the same page, in a different
frame, etc).

In general though, Netscape likes to see the document. qualifier before the
form name. So try my_parm=document.thisForm.txtNDC.value;

If this doesn't work, then provide some more details about how the page and
form are setup or the actual code from the page.

-carl

"Jeff" <jeffm@earthlink.net> wrote:
>
>I have a javascript function where I assign the value of a textbox to a
variable.
>I have no problem in IE 4 but Nescape 4.x says there is a javascript error.
>
>
>The line is:
>
>my_parm = thisForm.txtNDC.value;
>
>But if I place the literal like this, it works:
>
>my_parm = "7007";
>
>
>What am I doing wrong?
>
>
Carl Cirillo at 2007-11-11 23:41:42 >