i am not getting dropdown with this code [duplicate]

?>
<script>
<?php
while($rowss = mysql_fetch_array($result2, MYSQL_ASSOC)){   
?>
var str="<?=$rowss["ingredient"]?>";
var str_array = str.split(',');
    for(var i = 0; i < str_array.length; i++) {
        // Trim the excess whitespace.
        str_array[i] = str_array[i].replace(/^\s*/, "").replace(/\s*$/, "");
        // Add additional code here, such as:
        var opt = document.createElement('option');
        opt.innerHTML = str_array[i];
        opt.value = str_array[i];
        sel.appendChild(opt);
    }
<?php
}
?>
</script>

Leave a Comment