Getting select's value with dynamic id
Hi;
I create multiple drop downs with php and they have different ids. For example:
-
<select name="product_type[1854]" id="p_type_1854"
onchange="update_template_for_download(p_type_1854);">
</select>
<select name="product_type[1854]" id="p_type_1855”
onchange="update_template_for_download(p_type_1855);”>
</select>
-
How can I get the value of selected option? I thought this does it but this alerts "[object HTMLSelectElement]":
- function update_template_for_download(id)
{
alert(id);
}
And alert($("#" + id).val()); alerts nothing!
Thanks