Created
July 8, 2019 07:31
-
-
Save anugrahbsoe/875b2a491757464ea4e8f838e9f81e4f to your computer and use it in GitHub Desktop.
pilih barang combobox
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<option selected="selected">---Pilih Barang--</option> | |
<?php | |
while ($row = mysqli_fetch_array($result)){ | |
echo '<option value="' . $row['nama'] . '">' . $row['nama'] . ' </option>'; | |
$jsArray .= "NamaBarang['" . $row['nama'] . "'] = {merk:'" . addslashes($row['merk']). "', | |
satuan:'" . addslashes($row['satuan']). "', jumlah:'" . addslashes($row['jumlah']). "', | |
foto:'" . addslashes($row['foto']). "'};\n"; | |
} | |
?> | |
</select> | |
</div> | |
<script type="text/javascript"> | |
<?php echo $jsArray; ?> | |
function changeValue(id){ | |
//document.getElementById('nama').value = NamaBarang[id].nama; | |
document.getElementById('merk').value = NamaBarang[id].merk; | |
document.getElementById('satuan').value = NamaBarang[id].satuan; | |
document.getElementById('jumlah').value = NamaBarang[id].jumlah; | |
document.getElementById('foto').value = NamaBarang[id].foto; | |
}; | |
</script> | |
<div class="form-group"> | |
<label>Merk</label> | |
<input name="merk" type="text" class="form-control" id="merk" disabled> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment