require "admin_common.php"; //require_once ("../include/posts.inc.php"); require_once "../include/category.inc.php"; ?> Please select the category and click OK<br> The category will be the starting category for the field. <form name="cat_selector" > <select height="10" name="select" onchange="change_it(); "> <option value="0">[Select Starting Category]</option> <?php //showCatOptions ( 0, "Main"); $form_id = $_REQUEST['form_id']; if ($form_id == '') { $form_id = 1; } category_option_list2(0, $selected, $form_id); ?> </select> <input type="button" value="OK" onclick="window.close()" > </form> <script> function change_it() { var selectBox = document.forms[0].select; user_input = selectBox.options[selectBox.selectedIndex].value user_text = selectBox.options[selectBox.selectedIndex].text window.opener.document.form2.category_init_id.value = user_input; window.opener.document.form2.category_init_name.value = user_text;
function category_option_list2($category_id, $selected) { if (func_num_args() > 2) { $form_id = func_get_arg(2); $form_id_sql = " AND `form_id`={$form_id} "; } global $depth, $cat_names; if ($depth == '') { $depth = 0; } if ($_SESSION['MDS_LANG'] == '') { $query = "SELECT * FROM categories WHERE category_id={$category_id} {$form_id_sql} ORDER by list_order, category_name "; } else { $query = "SELECT *, t2.category_name as NAME FROM categories as t1, cat_name_translations as t2 WHERE t1.category_id=t2.category_id AND t1.category_id={$category_id} AND t2.lang='" . $_SESSION['MDS_LANG'] . "' {$form_id_sql} ORDER by list_order, t2.category_name "; } //echo "<option>$query</option>"; $result = mysql_query($query) or die(mysql_error()); $row = mysql_fetch_array($result, MYSQL_ASSOC); $cat_names[$depth] = $row['NAME']; if ($depth != 0) { if ($row['category_id'] == $selected) { $sel = " selected "; } //if ($row['allow_records']=='Y') { echo "<option " . $sel . " value='" . $row['category_id'] . "'>"; for ($i = 0; $i < count($cat_names); $i++) { if ($i > 0) { $j = " -> "; } echo $j . $cat_names[$i]; } echo "</option>"; //} } $query = "SELECT * FROM categories WHERE parent_category_id='{$category_id}' {$form_id_sql} ORDER by list_order, category_name "; $result = mysql_query($query) or die(mysql_error()); while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $depth++; category_option_list2($row['category_id'], $selected); unset($cat_names[$depth]); $depth--; } }