Fully responsive globals.php with vertical menu (#2460)
[openemr.git] / interface / super / layout_listitems_ajax.php
blobfcd94b6649de9ca1cb1734eaffe12073bd14cb65
1 <?php
2 /**
3 * Given a list ID, name of a target form field and a default value, this creates
4 * JavaScript that will write Option values into the target selection list.
6 * @package OpenEMR
7 * @link http://www.open-emr.org
8 * @author Rod Roark <rod@sunsetsystems.com>
9 * @author Brady Miller <brady.g.miller@gmail.com>
10 * @copyright Copyright (c) 2014-2016 Rod Roark <rod@sunsetsystems.com>
11 * @copyright Copyright (c) 2018 Brady Miller <brady.g.miller@gmail.com>
12 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
16 require_once("../globals.php");
18 //verify csrf
19 if (!verifyCsrfToken($_GET["csrf_token_form"])) {
20 csrfNotVerified();
23 $listid = $_GET['listid'];
24 $target = $_GET['target'];
25 $current = $_GET['current'];
27 $res = sqlStatement("SELECT option_id FROM list_options WHERE list_id = ? AND activity = 1 " .
28 "ORDER BY seq, option_id", array($listid));
30 echo "var itemsel = document.forms[0][" . js_escape($target) . "];\n";
31 echo "var j = 0;\n";
32 echo "itemsel.options[j++] = new Option(" . js_escape("-- ".xl('Please Select')." --") . ",'',false,false);\n";
33 while ($row = sqlFetchArray($res)) {
34 $tmp = js_escape($row['option_id']);
35 $def = $row['option_id'] == $current ? 'true' : 'false';
36 echo "itemsel.options[j++] = new Option($tmp,$tmp,$def,$def);\n";