I have a Jquery post script, which for reasons outside of my control has to be placed on a page by use of echo from PHP. Now the issue is that I need to pass information from a form on the page into the data to be posted.
Here is the working script at the moment:
echo '<script type="text/javascript">
$(".discuss_your_report").click( function() {
$.post(\'/layout/standard/report-action.php\', {
form: "discuss_your_report", website: "'.$_GET['website'].'", name: "'.$_GET['name'].'", email: "'.$_GET['email'].'", phone: ""},
function(data){
$(".message").html(data);
$(".message").show("slow");
}
);
</script>';
In the above script the phone number is empty, this needs to be entered by the user in the page using a standard form input. I have tried many things that have not worked, this being the latest:
echo '<script type="text/javascript">
$(".discuss_your_report").click( function() {
var phone = $(\'#phone\').val();
$.post(\'/layout/standard/report-action.php\', {
form: "discuss_your_report", website: "'.$_GET['website'].'", name: "'.$_GET['name'].'", email: "'.$_GET['email'].'", phone: "phone"},
function(data){
$(".message").html(data);
$(".message").show("slow");
}
);
</script>';
For ease of readibility, here it is without the PHP code:
<script type="text/javascript">
$(".discuss_your_report").click( function() {
var phone = $('#phone').val();
$.post('/layout/standard/report-action.php', {
form: "discuss_your_report", website: "www.example.com", name: "my name", email: "info@example.com", phone: "phone"},
function(data){
$(".message").html(data);
$(".message").show("slow");
}
);
</script>
But this just passes the text ‘phone’. Does anyone know how I can get this to work, any feedback is appreciated. Thanks
have changed var phone to phone_val, have assigned it with phone: phone_val without quote