knave
08-17-2005, 03:51 AM
what i have is a page with a table full of form fields, and a button that, when i click it, should add another row into said table. i want the user to be able to add and delete as many as they want, and they all would have id's such as 'field1', 'field2', etc. the thing is, i can't seem to write a static function to handle this indeterminate amount of html objects. i have an example of the page here (http://www.coro36ink.com/e/table.html).
i thought perhaps i could use eval():
function modifyField(num) // num of the row to work with
{
eval('field'+num+'.someproperty = "somevalue";');
}
thus i could call it like modifyField(1) to have it work with document.field1, etc. however, this doesnt work. even when i hardcode the object in (a span with an id="field1"), i get the error "field1 is not an object", when i try to refer to it from within an eval().
is there ANY way to do this with javascript? i really dont want to have to put such a repetetive load on a server-side script...
i thought perhaps i could use eval():
function modifyField(num) // num of the row to work with
{
eval('field'+num+'.someproperty = "somevalue";');
}
thus i could call it like modifyField(1) to have it work with document.field1, etc. however, this doesnt work. even when i hardcode the object in (a span with an id="field1"), i get the error "field1 is not an object", when i try to refer to it from within an eval().
is there ANY way to do this with javascript? i really dont want to have to put such a repetetive load on a server-side script...