746e8fd0 by Marty Penner

Admin user now able to set no location for country and province/state on event e…

…dit page; select lists now populate properly. refs #1222
1 parent deeada06
......@@ -190,7 +190,7 @@ if ( ! function_exists('form_dropdown'))
}
}
function form_linked_dropdown($name = '', $parent = '', $options = array(), $parent_selected = '', $selected = '', $extra = '')
function form_linked_dropdown($name = '', $parent = '', $options = array(), $parent_selected = '', $selected = '', $extra = '', $provide_js = true)
{
if ($extra != '') $extra = ' '.$extra;
......@@ -206,6 +206,7 @@ function form_linked_dropdown($name = '', $parent = '', $options = array(), $par
}
}
if ($provide_js) {
$form .= '</select>
<script>
function update_' . $name . '(value) {
......@@ -214,8 +215,8 @@ function form_linked_dropdown($name = '', $parent = '', $options = array(), $par
return;
}
jQuery("#'.$name.'_custom").attr("disabled","disabled").hide();
jQuery("#'.$name.'").show();
jQuery("#' . $name . '_custom").attr("disabled","disabled").hide();
jQuery("#' . $name . '").show();
var options = new Array();
......@@ -230,15 +231,15 @@ function form_linked_dropdown($name = '', $parent = '', $options = array(), $par
foreach ($v as $value => $content) {
$form .= '"' . $value . '","' . $content . '",';
}
$form = substr($form,0,-1);
$form = substr($form, 0, -1);
$form .= ');
break;';
}
$form .= 'default:
select.disabled = true;
jQuery("#'.$name.'").after("<input type=\'text\' name=\''.$name.'\' id=\''.$name.'_custom\' class=\'input-field-css input-large\' value=\''.$selected.'\' />").removeAttr("disabled").show();
jQuery("#'.$name.'").hide();
jQuery("#' . $name . '").after("<input type=\'text\' name=\'' . $name . '\' id=\'' . $name . '_custom\' class=\'input-field-css input-large\' value=\'' . $selected . '\' />").removeAttr("disabled").show();
jQuery("#' . $name . '").hide();
//options = new Array("other","Other");
return;
}
......@@ -254,17 +255,26 @@ function form_linked_dropdown($name = '', $parent = '', $options = array(), $par
var val = options[i++];
option.value = val;
option.innerHTML = options[i++];
if (val == "'.$selected.'") {
if (val == "' . $selected . '") {
option.selected = true;
}
select.appendChild(option);
}
}
update_'.$name.'(document.getElementById("'.$parent.'").value);
update_' . $name . '(document.getElementById("' . $parent . '").value);
document.getElementById("' . $parent . '").onchange = function() { update_' . $name . '(this.value); }
</script>
';
} else {
$form = '';
if (array_key_exists($parent_selected, $options)) {
foreach ($options[$parent_selected] as $name => $option) {
$sel = ($selected == $name) ? ' selected="selected"' : '';
$form .= '<option value="' . $name . '"' . $sel . '>' . $option . "</option>\n";
}
}
}
return $form;
}
......