不知道如何使用jquery或javascript来获取onchange()值和onclick()值 我想要onchange(VALUE)和onclick(VALUE)
<?php
include "koneksi.php";
if(isset($_GET["no_faktur"]))
{
$query = "SELECT * FROM faktur WHERE no_faktur = '".mysql_real_escape_string($_GET["no_faktur"])."';";
$sql = mysqli_query($connect, $query);
$count = mysqli_num_rows($sql); //Added from this line to whileloop.. Why because Each product is one row ...
if($count)
{
while($data = mysqli_fetch_array($sql))
{
echo ("<tr><td>".$data['no_faktur'].
"</td><td>".$data['nama_supplayer'].
"</td><td>".$data['tanggal'].
"</td><td>".$data['kode_barang'].
"</td><td>".$data['nama_barang'].
"</td><td>".$data['qty'].
"</td><td>".$data['harga_beli'].
"</td><td>".$data['jumlah'].
"</td></tr>");
}
}
else
{
echo("<h3 style=\"color: red;\">Nomor faktur ".$_GET["no_faktur"]." didn't found</h3>");
}
}
else
{
echo("<h3 style=\"color: red;\">Tidak ada produk yang ditampilkan</h3>");
}
?>
获得3,3
或
<input type="checkbox" name="category[]" id="category" value="3" onchange="box_val('3','3')">
获得3,3
或
修改get onchange(VALUE)和onclick(VALUE) box_val('3','3')到box_val('4','4')
答案 0 :(得分:1)
虽然困扰我为什么你需要两个事件
$('#category').on('click change', function(e) {
if (e.type == 'click') {
console.log('click')
}
if (e.type == 'change') {
console.log('change')
}
})
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input type="checkbox" name="category[]" id="category" value="3" />
&#13;
答案 1 :(得分:0)
试试这个。
function box_val(Text){
alert(Text);
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input type="checkbox" name="category[]" id="category" value="3" onchange="box_val($(this).val());">
<input type="text" name="category[]" id="category" value="3" onclick ="box_val($(this).val());">
答案 2 :(得分:0)
你下面的脚本
<script>
function myFunction(x,y) {
alert(x,y);
}
</script>
答案 3 :(得分:0)
$("#category").change(function(){
$('#category').val('3');
});
$('#category').click (function () {
$('#category').val('3');
});
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input type="text" name="category[]" id="category" value="1">
&#13;
希望这会对你有所帮助。