CodeIgniter Forums

Full Version: form_dropdown and javascript
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

hi everyone,

I've got the following code:
// $clubs is an array
echo form_dropdown('ddlClubs', $clubs);

when I want to het the selected value with javascript I have an error (object is null)

var e = document.getElementById("ddlClubs");

When I change the form_dropdown to the html <input> tag, it works fine.

What have I forgotten in the code?

The form_dropdown is server code and the javascript is client code so normally the dropdown should be accessible.



El Forum

The first parameter sets the name of the dropdown not the id.

echo form_dropdown('ddlClubs', $clubs, 0, 'id="ddlClubs"');

El Forum

thanks! problem solved!