如何将javascript变量传递给PHP变量? 在这里,我在特定图形栏上使用 onclick 函数来获取类似('Apr-2019')的条的属性值,并将该值传递给引导模态。
这是我的图形代码:在这里,我正在执行click函数以获取属性值
var chart = Highcharts.chart('container_eight', {
title: {
text: ''
},
xAxis: {
categories: ['Apr-2019', 'Mar-2019', 'Feb-2019', 'Jan-2019'],
reversed: true
},
yAxis: {
title: {
text: 'Number of Users'
}
},
plotOptions: {
series: {
cursor: 'pointer',
point: {
events: {
click: function display() {
$('#myModal').modal('show');
var category_val = $(this).attr('category');
document.getElementById('category').innerHTML = category_val;
alert(category_val);
}
}
}
}
},
series: [{
type: 'column',
color:'#BEDB39',
data: [<?php echo $final_active_users ?>],
showInLegend: false
}]
});
});
modal code in the same page: here I am passing variable from javascript(category_val ) inside bootstrap modal
<?php
$data = '<p id="category"> </p>';
echo $data;
?>
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" data-backdrop="false">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title w-100" id="myModalLabel">Total Active Users</h4>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body" id="container_modal">
<?php
$data = '<p id="category"> </p>';
echo $data;
?>
</div>
</div>
</div>
</div>
在单击时,条形图需要获取属性的值 预期产量:2019年4月