Hi all,`
The below code is giving me problems.
<?php
$ddaa = $pdo->query("SELECT id, stockname, stockno, producer FROM storemaster order by stockname");;
while ($data = $ddaa->fetch(PDO::FETCH_ASSOC))
{
echo '<option value="'.$data['stockno'].'" data-producer="'.$data['producer'].'"> '.$data['stockname'].'</option>';
}
?>
This is the script:
<script>
$('#stockname').on('change',function(){
if($(this).val() !=0){
$('#stockno').val($(this).val());
$('#producer').val($(this).attr('data-producer'));
}
});
</script>
All I wanted from this code is when I click a stockname from the dropdown list, The stockno and producer textbox should be fetched.
But now only the stockno is fetched and the producer is null.
Please help out.
Thank you.
Emeka
Emeka_2
0
Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.