We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 2364
    • 73 Posts
    Hi!
    I wrote function, which output combobox. Then I want insert it in following construction:
    ........
    $output .= '<div class="formclass"><form name="name" method="post" action="">'
     . showCB() . '';
    $output .= '</form></div>';
    ........
    

    My combobox is showing at the end of the page, not in <DIV>. How call function, that the result was there where it is necessary?
    huh
      • 18397
      • 3,250 Posts
      1. Can you provide us with the code of the function?
      2. Are you returning (correct method) or echoing the output in the function?
        • 2364
        • 73 Posts
        Simple code:
        function showCB() {
        	global $modx;
        	global $_lang;
        	$sectortable = $modx->getFullTableName('jobsector');
        	$sectors = $modx->db->select('id,name', $sectortable,'','id ASC');
            $show_Combo_Box = ""
            ."<select size=\"1\" name=\"selectsector\">"
            ."<option value=\"0\">" . $_lang['EM_sel_sector'] . "</option>";
            WHILE ($row = mysql_fetch_array($sectors)) {
        
        				$show_Combo_Box .= ""
        				."<OPTION value=\"".$row[0]."\">"
        				.$row[1]
        				."</OPTION>";
        			}
        			$show_Combo_Box .= ""
        			."</SELECT>";
        			return $show_Combo_Box;
        }
        

        ohhhh.... sorry, while write this reply, found error - I write echo $show_Combo_Box; rolleyes