I understand that there are existing questions and answers that have already addressed this matter. I\'ve looked through them but my situation doesn\'t allow me to apply the
What I'm really trying to achieve:
PHP variables getting JavaScript values in the same page in a Facebook iFrame. It is all right for the page to reload to pass parameter to itself.
Easiest way: Generate a form element, populate it with some (hidden) input fields, and POST it to your server.
AJAX is also possible, and maybe nicer for the user as it doesn’t require a reload.
Since your’re not describing any problem in detail, I can only assume it’s mostly due to a general lack of knowledge/experience in these matters on your part. So maybe look for some tutorials first, to get a general understanding of the techniques involved.
It's still not clear whether you want to:
pass data that you receive in PHP via app_data
to JavaScript, or
pass data from JavaScript to PHP.
<head>
<script type="text/javascript">
var app_data = <?php echo json_encode($appData); ?>;
</script>
</head>
<body>
...
$.ajax({
url: location.pathname, // current page
type: 'POST',
data: {
vara: 'hello',
varb: 'world'
},
success: function() {
// ...
}
});
You can do that easily with javascript for example HTML code:
<select id = "Select" onchange = "FijarPrecio (this.id);" >
<option value = "10"> product 1 </ option>
<option value = "20"> product 2 </ option>
<option value = "30"> product 3 </ option>
</select>
<input type = "text" name = "Price" id = "Price"/>
<script type = "text/javascript" >
FijarPrecio function (id) {
PrecioSel var = document.getElementById (id);
PrecioActual var = document.getElementById ('Price');
PrecioActual.value = PrecioSel.value;
}
</script>