Move the JS that re-enables opt textbox fields to the end of the form, so that it has access to the correct state https://sourceforge.net/p/webadmin/bugs/4293/

This commit is contained in:
Jamie Cameron
2013-09-01 22:48:35 -07:00
parent cbc918d741
commit 48a7bb620d

View File

@@ -659,6 +659,14 @@ if ($buttons && @$buttons) {
$rv .= "</tr></table>\n";
}
$rv .= "</form>\n";
# When going back to a form, re-enable any text fields generated by
# ui_opt_textbox that aren't in the default state.
$rv .= "<script>\n";
$rv .= "var opts = document.getElementsByClassName('ui_opt_textbox');\n";
$rv .= "for(var i=0; i<opts.length; i++) {\n";
$rv .= " opts[i].disabled = document.getElementsByName(opts[i].name+'_def')[0].checked;\n";
$rv .= "}\n";
$rv .= "</script>\n";
return $rv;
}
@@ -1230,7 +1238,6 @@ $rv .= "<input class='ui_opt_textbox' name=\"".&quote_escape($name)."\" ".
($max ? " maxlength=$max" : "").
" ".$tags.
">\n";
$rv .= "<script>if ($ui_formcount < document.forms.length) { document.forms[$ui_formcount].$name.disabled = document.forms[$ui_formcount].${name}_def[0].checked; }</script>\n";
return $rv;
}