How to step JavaScript value to PHP?
The value (passValue)
Or the value you have on the "on " or "off " button
for here $testup = (passValue);
Sorry bad English
<button id="toggle" name="test11" onclick="myFunction20()" value="on">on</button>
<script type="text/javascript" src="https://code.jquery.com/jquery-3.4.1.min.js"></script>
<script>
function myFunction20() {
var change = document.getElementById("toggle");
var passValue = change.value;
if (change.innerHTML == "on")
{
change.innerHTML = "off";
change.value= "off";
}
else {
change.innerHTML = "on";
change.value= "on";
}
<?php $plugins_url = plugins_url();?>
$.ajax({
type: 'POST',
url: "<?=$plugins_url.'/enhanced-text-widget/updatebutton.php';?>",
cache: false,
data: {
<?php
$testup = (passValue);
update_post_meta('20', 'tracks-info', $testup ); ?>
},
success: function(html){
alert(html)
return false;
}
});
alert(passValue);
}
</script>