0
<?php
    $options = array();
    $options[0] = "Kies het kampioenschap";
    foreach ($kampioenschappen as $kampioenschap) {
        $options[$kampioenschap->kampioenschapsId] = $kampioenschap->naam;
    }
    $js = 'id="kampioenschap" style="width: 600px';
    echo form_dropdown('kampioenschap', $options, '0', $js) . "\n";
?>

I want to create a dropdown form so the user can select a championship that he wants to view.

This all works but I have a problem with showing the first value in the $options array. In the CodeIgniter docs they say:

echo form_dropdown('name', $options, 'selectedvalue', $js);

If I look at the source output in my browser, this is what I see:

    <select name="kampioenschap" id="kampioenschap" style="width: 600px>
    <option value="0" selected="selected">Kies het kampioenschap</option>
    <option value="2">Nationaal kampioenschap</option>
    <option value="3">Waals kampioenschap</option>
    <option value="5">Vlaams kampioenschap</option>
    </select>

For me this looks like valid xhtml code. But when I open the page with Firebug or DragonFly, I get this:

<select id="kampioenschap" 
selected="selected" 0"="" style="width:    600px> 

This makes no sense to me, I have other dropdown in my application that work just fine.

Can someone point out the mistake I made?

1 Answer 1

2

You forgot the last quote here:

$js = 'id="kampioenschap" style="width: 600px';

Replace it with this:

$js = 'id="kampioenschap" style="width: 600px"';
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.