Ok, so I've hacked my way through this problem but I'm hoping someone here can guide me to a better way to handle this. I'm trying to read all properties from a fieldset on a custom character sheet, however i can't seem to target any attribute that will return an object of all the values. I'm resorting to building the properties names by hand until one breaks, which feels terrible to do. Is there a better, cleaner way to do this? The HTML <fieldset class="repeating_moves">
<input type="text" name="attr_condition" />
</fieldset> The JS Hack
//Using a while loop because there is no theoretical upper limit on i
function getConditions(char){
var conditions = [];
var i = 0;
var no_error = true;
while(no_error){
var condition = getAttrByName(char.id, "repeating_moves_"+i+"_condition");
if(condition){
conditions.push(condition);
i++;
} else {
no_error = false;
}
}
//Pleaseing UI message for no conditions
if(conditions.length < 1){
conditions.push("No conditions, go do something interesting");
}
return conditions;
}