I have a select filled from database:
<?php
$query = mysql_query("SELECT * FROM users");
if(mysql_error())
{
print(mysql_error());
}
echo'<select id="dropdown2" id="user_id" name="user_id" data-placeholder="[Select]" class="select" style="width:350px;" tabindex="2")">';
echo'<option value=""></option>';
{
while($row = mysql_fetch_array($query))
echo'<option value="'.$row['user_id'].'">'.$row['user_name'].'</option>';
}
echo'</select>';
?>
I need to on submit pass dropdown value on js variable
I'm trying in this way, but variable is blank:
<script language="JavaScript">
var dropdown_value = $('#user_id option:selected').val();;
</script>
Any help?