Collections functions
Encryption functions
General functions
Render functions
Theme permission functions
Video functions
Resource functions

render_dropdown_question()

Description

render_dropdown_question - Used to display a question with a dropdown selector

Parameters

ColumnTypeDefaultDescription
$label string Label of question
$inputname string Name of input field
$options array array Array of options (value and text pairs) (eg. array('pixelwidthmin'=>'From','pixelwidthmin'=>'To')
$current string "" The current selected value
$extra string "" Extra attributes used on the selector element
$ctx array array Rendering context. Should be used to inject different elements (e.g set the div class, add onchange for select)

Return

void

Location

include/render_functions.php lines 1391 to 1420

Definition

 
function render_dropdown_question($label$inputname$options = array(), $current=""$extra="", array $ctx = array())
    {
    
$div_class = array("Question");
    if(isset(
$ctx["div_class"]) && is_array($ctx["div_class"]) && !empty($ctx["div_class"]))
        {
        
$div_class array_merge($div_class$ctx["div_class"]);
        }

    
$onchange = (isset($ctx["onchange"]) && trim($ctx["onchange"]) != "" trim($ctx["onchange"]) : "");
    
$onchange = ($onchange != "" sprintf("onchange=\"%s\""$onchange) : "");

    
$extra .= {$onchange}";
    
?>
    <div class=" echo implode(" "$div_class); ?>">
        <label> echo $label?></label>
        <select  name=" echo $inputname?>" id=" echo $inputname?> echo $extra?>>
        
        
foreach ($options as $optionvalue=>$optiontext)
            {
            
?>
            <option value=" echo htmlspecialchars(trim($optionvalue))?> if (trim($optionvalue)==trim($current)) {?>selected ?>> echo htmlspecialchars(trim($optiontext))?></option>
            
            
}
        
?>
        </select>
        <div class="clearerleft"></div>
    </div>
    
    
return;
    }

This article was last updated 24th November 2020 20:35 Europe/London time based on the source file dated 13th November 2020 15:00 Europe/London time.