Jump to content

Recommended Posts

I posted a topic a few days ago but no one responded. I have taken another stab at reducing the old code and adding a standard drop-down list but the list is only populating with 1 result and the one result doesn't submit the actual id to the submit function. Can someone please look at the original piece of code below and my attempt at the drop down list and offer any suggestions? Thanks...

 

 

Current multi-select code:

 

 

$iteration =0;

$skills = $skillChapter['Skill'];

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>";

$iteration++;

echo "</div>";

 

 

 

 

My attempt to convert to a standard (single select) drop-down list. Below code is not working:

 

 

echo "<div class=\"floatClear\">";

echo $form->input( 'data[Job][skill".$skillid."]', array( 'label' => 'Select a Function', 'type'=>'select', 'options'=>

array("$skill".$skill['id'])));

echo "</div>";

Link to comment
https://forums.phpfreaks.com/topic/140471-help-w-drop-down-list-made-more-simple/
Share on other sites

Don't know exactly what you're doing but you have an opening <input> and no closing </input> in the foreach loop which could be why you are only getting 1 option. Also, if you use single quote on the echo calls you don't have to delimit the "s in the output, so:

 

echo "<input type=\"checkbox\" name=\"data[Job][skill".$skillid."]\" value=\"1\" id=\"skill".$skillid."\"> ";
echo "<label for=\"skill".$skillid."\">{$skill['title']}</label>";

would become:

echo '<input type="checkbox" name="data[Job][skill'.$skillid.']" value="1" id="skill'.$skillid.'\"> ';
echo '<label for="skill'.$skillid.'">{$skill['title']}</label>';

 

Which is a lot easier to read if you ask me. If echo() doesn't like single quotes you can use print('text'); instead.

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.