Hello I need help on this, I have this code
<a href="javascript:void(0);" onclick="removerow('.$row["sn"].');">
<i class="fa fa-remove" style="color: red"></i>
</a>
and i need to get value from onclick="removerow('.$row["sn"].')
to this function
function removerow()
{
var vpb_sn = _______.val();
}
Pass value:
onclick="removerow('.$row["sn"].');"
Accept it:
function removerow(value)
{
// and you can use it just like variable
console.log(value);
}
Sends var to php file (using jquery ajax):
function removerow(value)
{
$.ajax({
url: 'index.php', // here path to php file
type: 'post', //type of a query
data: {myVariable: value}, // data which sends into php file
success: function (data) {
alert('sended successfully!');
}
});
}
And then, inside index.php (file, on which data was sended), we can saw our data using this:
$_POST['myVariable'];
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.