I have been pulling my hair out trying to convert a piece of custom code a previous developer deployed. The developer created a custom multi-select drop-down that returns back a seperate list for each category it finds in the database. The client wanted to only display the first category in the database so I simply added a “break’ to stop after displaying the first category. This was only a quick fix and since then I have been trying to get rid of the custom multi- select drop-down and replace it with just a simple drop-down that only allows the user one selection. I have tried numerous things but because the original code doesn’t specify an actual value I cannot seem to get a single standard drop down created using the “break” to show only the first category from the database. Below is the snippet of original .html from the page. I have to leave the javascript as that is used to display what is selected in the drop down in another area of the page. Any help greatly appreciated:
echo $form->create( ‘Job’, array( ‘action’ => ‘index’ ) ).”n”;
echo “<div class=”row”>”;
echo ‘<h4 class=”filter1″>Select your function:</h4>’;
foreach ($skillChapters as $skillChapter)
break;
{
$currid = $skillChapter[‘SkillChapter’][‘id’];
echo “<div class=”selectSkillHm”>”;
echo “<div class=”floatLeft” onclick=”showHideFront(‘showchapter”.$currid.”‘,’showRightMinus”.$currid.”‘,’showRightPlus”.$currid.”‘)”>”.$skillChapter[‘SkillChapter’][‘title’].”</div>”;
echo “<div class=”floatRight” onclick=”showHideFront(‘showchapter”.$currid.”‘,’showRightMinus”.$currid.”‘,’showRightPlus”.$currid.”‘)”>”;
echo “<span class=”showElement” id=”showRightPlus”.$currid.””>+</span><span class=”hideElement” id=”showRightMinus”.$currid.””>(Close)</span>”;
echo “</div>”;
// $skillCategories = $skillChapter[‘SkillCategory’];
echo “<div class=”hideSkillBox” id=”showchapter”.$currid.””>”;
$iteration =0;
$skills = $skillChapter[‘Skill’];
$skilIds = array();
foreach ($skills as $skill)
{
$skillid = $skill[‘id’];
$skillIds[] = array(“skill”.$skill[‘id’],$skill[‘title’],$skillChapter[‘SkillChapter’][‘title’]);
echo “<div class=”skillRow”>”;
echo “<input type=”checkbox” name=”data[Job][skill”.$skillid.”]” value=”1″ id=”skill”.$skillid.””>”;
echo “<label for=”skill”.$skillid.””>{$skill[‘title’]}</label>”;
echo “</div>”;
}
echo “</div>”;
echo “</div>”;
}
$iteration++;
echo ‘<script type=”text/javascript”>’;
echo ‘var SKILLS = [‘;
for ($i=0; $i < count($skillIds); $i++) {
echo ‘[“‘.$skillIds[$i][0].'”,”‘.$skillIds[$i][1].'”,”‘.$skillIds[$i][2].'”]’;
if ($i < count($skillIds)-1) {
echo “,”;
}
}
echo ‘];’;
echo ‘</script>’;
echo “</info></div>”;
echo “<div id=’selectedSkills’ style=’display:none;’></div>”;