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.
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");
19 if (!verifyCsrfToken($_GET["csrf_token_form"])) {
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";
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";