Originally posted by Tom Obermeyer:
Thanks,
I actually came up with a solution, somewhat similar to yours. I post the form to a handler that distinguishes between adding, removing, and submitting (saving). On the form, each input is given a name like "inputName" + i, where i is the current count of the total number of rows of input boxes. I have a custom tag that iterates through the count, displaying the input tag--along with it's value, if any--for the current row count.
in any of the three cases, the handler will iterate through the total row count, taking the current row's "inputName"+i, creating the object that holds this value, and putting this object into a hashtable with the key being the current row count.
the handler puts the hashtable on the request and forwards back to the original page. then the page enumerates through the hashtable, displaying the input value stored in each object.
this way, i can add some rows, enter some inputs, then add more rows and keep the old input values.
for add, the handler will add N new objects to the hashtable, starting at row count + 1.
each row has a checkbox next to the input box. so for delete, i simply check the value of the checkbox for the current row count value, and then delete it.
the input box is required. but for add and delete, if the input box is empty, an error message won't be displayed. this keeps the page clean while the user is editing. of course, doing submit (save) will validate completely.
Right! We're on it! Let's get to work tiny ad!
Smokeless wood heat with a rocket mass heater
https://woodheat.net
|