I want to use the value from input file hidden when I am doing click on href.
<a href="#" onclick="invoice_open(<?php echo $counter?>);">confirm</a>
function invoice_open(i){
var x = document.getElementById("inv"+i).value;
alert(x);
window.scrollTo(0,0);
document.getElementById('light').style.display='block';
document.getElementById('fade').style.display='block';
}
I already success to get the value from input type hidden (var x), but I don't know how to pass x value to php ex. $result = x.
I want to use $result for display data from my database. Please help. Thank you
since you already get the values using <?php echo $counter?>
then you can do
var counter = '<?php echo $counter?>'
in javascript. And typical AJAX approach would be like the following..
$.ajax({
url: 'index.php&counter=' + counter,
dataType: 'json',
beforeSend: function() {
},
complete: function() {
},
success: function(json) {
// do something with DOM, redirect ... etc
},
error: function(xhr, ajaxOptions, thrownError) {
// handles exception
}
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.