Ok so this may be a dumb question (probably some syntax) but Google didn't tell me much about why this isn't working, so here goes.
I have a function append_..._fields that takes an arbitrary amount of arguments, first one being the id of what to add fields onto, and all following are just names for the fields. It's hacked together so there are probably a couple things I could improve. This function appears in an imported script type="text/javascript" tag in as generated by rails
append_widget_form_fields = function(a){
var widget_el = $(arguments[0]);
var new_li = Element.new("li", class : widget_el.id, id : widget_el.id+"_new");
for (var field in arguments) {
if (field == arguments[0]){} // ignore first arg.
else { //inserts fields into <li>
Element.insert(new_li, { bottom : get_input_box_from_field_name( field , widget_el.id )});
}
} // inserts <li> into widget
Element.insert(widget_el, { bottom : new_li });
}
Either way, I don't see anything wrong with it in terms of how I define it. I did try adding a var in front of it all - didn't help. The way the function is called is:
<input type="button" value="Add Fields" onclick="append_widget_form_fields('some_widget_id', 'headline', 'author', 'link');"/>
Addendum question: JS should syntax error when something is wrong with the function, and not scrap the definition, correct?