function formPrep() { if(wgPageName.indexOf("Special:FormEdit") > -1 || wgAction.indexOf("formedit") > -1) { function modify_selected_values() { var input = $(this).parent().prev('span').children('input'); var chk_value = this.value; var selected_values = input.val() ? input.val().split(/ *, */) : []; if(this.checked) { selected_values.push(this.value); selected_values.sort(); } else { selected_values = $.grep(selected_values, function(value) { return value != chk_value; }); } input.val(selected_values.join(", ")); } function property_list_to_checkboxes() { var property_list = this; var input = $(this).prev('span').children('input'); var available_values = $(this).text().split(", "); var selected_values = input.val() ? input.val().split(/ *, */) : []; $(this).text(""); var name = "chk_" + input.attr('name'); $.each(available_values, function() { var chk = $(' -1 ? ' checked="checked"' : '') + ' />'); $(property_list).append(chk); chk.change(modify_selected_values); $(property_list).append(document.createTextNode(" " + this + " ")); }); $(this).show(); } $(function () { $('.property_list').each(property_list_to_checkboxes); }); } } addOnloadHook(formPrep);