SitePoint Sponsor |
|
User Tag List
Results 1 to 2 of 2
Thread: Dynmic form buttons
-
Sep 5, 2001, 13:39 #1
- Join Date
- Jun 2001
- Location
- Edinburgh, UK
- Posts
- 51
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Dynmic form buttons
I have a form that has a set of buttons that i want to change the appearance of when they are clicked. I can do this by specifying the button name directly, but i'd like to be able to do it with dynamically. For example:
I can do this:
formObj.button1.value += "*";
formObj.button2.value += "*";
etc etc
But i want to do something like this (which doesn't work!)
whichbutton = "button" + bnumber;
formObj[whichbutton].value += "*";
I gues it doesn't work because i'm trying to specify an object with a standard variable, so how do i change it to make it work?
Cheers.Become Interactive because its all gone a bit subBlue
-
Sep 5, 2001, 20:01 #2
- Join Date
- Feb 2000
- Location
- where the World once stood
- Posts
- 700
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Hi Tom,
Use the eval() for what you want
for (i=1; i <= numOfButtons; i++)
{
myButton = eval('document.formname.button' + i);
myButton.value = "*";
}
VinnyWhere the World Once Stood
the blades of grass
cut me still
Bookmarks