2
0
mirror of https://github.com/ACSPRI/queXS synced 2024-04-02 12:12:16 +00:00

Allowed for returning as a string instead of printing chooser

This commit is contained in:
Adam Zammit
2013-11-25 16:16:53 +11:00
parent d5f4ce65b3
commit 70b594853d

View File

@@ -161,48 +161,54 @@ function xhtml_table($content,$fields,$head = false,$class = "tclass",$highlight
* @param bool $js Whether to use JS or not * @param bool $js Whether to use JS or not
* @param bool $indiv Whether to display in a div or not * @param bool $indiv Whether to display in a div or not
* @param array|bool $select The element to select manually (element,string) (not using selected=\'selected\' in array) * @param array|bool $select The element to select manually (element,string) (not using selected=\'selected\' in array)
* @param bool $print Default is true, print the chooser otherwise return as a string
* *
*/ */
function display_chooser($elements, $selectid, $var, $useblank = true, $pass = false, $js = true, $indiv = true, $selected = false) function display_chooser($elements, $selectid, $var, $useblank = true, $pass = false, $js = true, $indiv = true, $selected = false, $print = true)
{ {
if ($indiv) print "<div>"; $out = "";
print "<select id='$selectid' name='$selectid' "; if ($indiv) $out .= "<div>";
if ($js) print "onchange=\"LinkUp('$selectid')\""; $out .= "<select id='$selectid' name='$selectid' ";
print ">"; if ($js) $out .= "onchange=\"LinkUp('$selectid')\"";
$out .= ">";
if ($useblank) if ($useblank)
{ {
print "<option value='"; $out .= "<option value='";
if ($js) print "?"; if ($js) $out .= "?";
if ($pass != false) if ($pass != false)
print $pass; $out .= $pass;
print "'></option>"; $out .= "'></option>";
} }
foreach($elements as $e) foreach($elements as $e)
{ {
if ($js) if ($js)
{ {
print "<option value='?$var={$e['value']}"; $out .= "<option value='?$var={$e['value']}";
if ($pass != false) if ($pass != false)
print "&amp;$pass"; $out .= "&amp;$pass";
print "' "; $out .= "' ";
} }
else else
{ {
print "<option value='{$e['value']}' "; $out .= "<option value='{$e['value']}' ";
} }
if ($selected == false) if ($selected == false)
{ {
if (isset($e['selected'])) if (isset($e['selected']))
print $e['selected']; $out .= $e['selected'];
} }
else else
if (strcmp($selected[1],$e[$selected[0]]) == 0) print "selected='selected'"; if (strcmp($selected[1],$e[$selected[0]]) == 0) $out .= "selected='selected'";
print ">".strip_tags($e['description'])."</option>"; $out .= ">".strip_tags($e['description'])."</option>";
} }
print "</select>"; $out .= "</select>";
if ($indiv) print "</div>"; if ($indiv) $out .= "</div>";
if ($print)
print $out;
else
return $out;
} }
function xhtml_object($data, $id, $class="embeddedobject") function xhtml_object($data, $id, $class="embeddedobject")