adressing formfields named with php array variables

Javascript coding ..

Moderators: macek, egami, gesf

Miss_Marple
New php-forum User
New php-forum User
Posts: 32
Joined: Tue Jul 30, 2002 11:27 pm

adressing formfields named with php array variables

Postby Miss_Marple » Tue Nov 25, 2003 7:31 am

Hi there,

I have a formular, where I named some of the textfields:
field[0], field[1], etc...
others I named word[0], word[1], etc...
Now I want to reset only some fields with a button. F.e. all 'fields' or all 'words'.
A document.formname.field.value=""; or something like that doesn't work, because I seemingly can't use fieldnames, which include brackets.

Any idea?

Thanks Alex

liquedus
php-forum Active User
php-forum Active User
Posts: 266
Joined: Tue Apr 08, 2003 5:18 am
Location: Ottawa, Canada
Contact:

Postby liquedus » Tue Nov 25, 2003 7:53 am

since you will be using JS, you could use eval()

and name your fields field0, field1....

then try something like this, tho i am not making any guarantees:

for(counter=0;counter<someVal;counter++){
eval("document.formname.field"+counter+".value=''")
}


:wink:


Return to “JavaScript”

Who is online

Users browsing this forum: No registered users and 1 guest