3 <SCRIPT TYPE="text/javascript">
5 % foreach my $type ('C','R') {
6 '<%$type%>': [<% join(',', map {"'$_'"} FS::radius_attr->ops($type)) %>],
9 function change_attrtype(what) {
10 var new_type = what.value;
11 var select_op = document.getElementById(
12 what.id.replace(/_attrtype$/, '_op')
15 var options = select_op.options;
16 var new_ops = ops_for_type[new_type];
17 while ( options.length > 0 )
19 for ( var x in new_ops ) {
20 // Option(text, value, defaultSelected)
21 options.add(new Option(new_ops[x], new_ops[x], (options.length == 0)));
24 <% $onchange %>(what);
28 <INPUT TYPE="hidden" NAME="<%$name%>" ID="<%$id%>" VALUE="<% $curr_value %>">
30 field => $name.'_attrtype',
31 id => $name.'_attrtype',
33 labels => { 'C' => 'Check', 'R' => 'Reply' },
34 curr_value => $radius_attr->attrtype,
35 onchange => 'change_attrtype(this)',
38 field => $name.'_attrname',
39 curr_value => $radius_attr->attrname,
40 onchange => $onchange,
41 size => 40, #longest attribute name in freeradius dict = 46
46 options => [ FS::radius_attr->ops($radius_attr->attrtype) ],
47 curr_value => $radius_attr->op,
48 onchange => $onchange,
51 field => $name.'_value',
52 curr_value => $radius_attr->value,
53 onchange => $onchange,
54 size => 20, #tend to be shorter than attribute names
63 # for an 'onchange' option that will work in both select.html and
65 # - don't start with "onchange="
66 # - don't end with (what) or (this)
67 # - don't end with a semicolon
69 my $onchange = $opt{'onchange'} || '';
70 $onchange =~ s/\((what|this)\);?$//;
72 my $name = $opt{'element_name'} || $opt{'field'} || 'attrnum';
73 my $id = $opt{'id'} || 'attrnum';
75 my $curr_value = $opt{'curr_value'} || $opt{'value'};
79 $radius_attr = qsearchs('radius_attr', { 'attrnum' => $curr_value })
80 or die "attrnum $curr_value not found";
83 $radius_attr = new FS::radius_attr {