Welcome Guest, Not a member yet? Register   Sign In
form_dropdown and javascript
#1

[eluser]filip_de_backer[/eluser]
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.

thanks

Filip
#2

[eluser]Kamarg[/eluser]
The first parameter sets the name of the dropdown not the id.

Code:
echo form_dropdown('ddlClubs', $clubs, 0, 'id="ddlClubs"');
#3

[eluser]filip_de_backer[/eluser]
thanks! problem solved!




Theme © iAndrew 2016 - Forum software by © MyBB