Accessing a field variable with spaces in it.. HELPPPPPPPPP !!!!

P

Pooj

I have a form having field as below :

<input type="text" maxlength="12" id="attributes1" name="Alert Code"
value="001" onChange="convert(this)">

I want to alert the value inputted by the user in this field. The form
name is MainForm. I used :

alert(document.MainForm["0_Alert Code"].value)

But it is giving some wiered numbers like 91807168

What does this mean How Can i alert the value entered ?

Please help this is very urgent !!!
 
H

Hywel

Pooj said:
I have a form having field as below :

<input type="text" maxlength="12" id="attributes1" name="Alert Code"
value="001" onChange="convert(this)">

I want to alert the value inputted by the user in this field. The form
name is MainForm. I used :

alert(document.MainForm["0_Alert Code"].value)

What's the "O_" for in that?
 
R

Randy Webb

Pooj said:
I have a form having field as below :

<input type="text" maxlength="12" id="attributes1" name="Alert Code"
value="001" onChange="convert(this)">


I want to alert the value inputted by the user in this field. The form
name is MainForm. I used :

Since you are passing a reference to the convert function, you can
simply use that reference:

function convert(fieldRef){
alert(fieldRef.value)
}
alert(document.MainForm["0_Alert Code"].value)

But it is giving some wiered numbers like 91807168

since you use 0_Alert Code in the script but Alert Code in the HTML, its
totally surprising you got the alert at all.
What does this mean How Can i alert the value entered ?

Please help this is very urgent !!!

Everything is "urgent" until you are dead, then it doesn't matter anymore.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,528
Members
45,000
Latest member
MurrayKeync

Latest Threads

Top