I am able to collect a form value and store it in a jquery var, which needs to be used in a php string.
I can get another var to output into a span tags, but cant get it to go into a the php string as below.
success: function (html) {
$('#namePay').val(hname.val() + " - Jumbo Tours");
var span = document.getElementById('namePay2');
var span2 = document.getElementById('description2');
span.firstChild.nodeValue = name.val();
span2.firstChild.nodeValue = hname.val();
$.fancybox({
content: $('#access-policy'),
modal: true
});
return false;
}
On success var span works here -
<p>Gracias <span id="namePay2"> </span>,</p>
But I need var2 to work in here -
$paymentString = "VendorTxCode=".$randNum."&Amount=167.00&Currency=EUR&Description=<span id='description2'></span>&CustomerName=FnameSurname&CustomerEMail=customer@example.com&BillingSurname=Surname&BillingFirstnames=Fname&BillingAddress1=BillAddressLine 1&BillingCity=BillCity&BillingPostCode=W1A1BL&BillingCountry=GB&BillingPhone=447933000000&DeliveryFirstnames=Fname&DeliverySurname=Surname&DeliveryAddress1=BillAddressLine1&DeliveryCity=BillCity&DeliveryPostCode=W1A1BL&DeliveryCountry=GB&DeliveryPhone=447933000000&SuccessURL=http://www.tourcheck.com/jumbotours/thankyou.php&FailureURL=http://www.tourcheck.com/jumbotours/failure.php";
Its the value I want for Description.
The above doesn’t work, so looking for some advice really.
Cheers
On the other hand if that var could be saved as a php variable that would do the trick, but what I was trying to do was insert a jquery value into a span which is inside a php string.
I just need that second value to be the value of Description -
&Description=in here&
So that I can pass this to sagepay to convert payments.
I have tried below which is posting the value from jquery, but I think im posting it to the wrong place, as basically whats happening in the code below is that its calling fancybox which then displays html, but what I would like to do is get my jquery value into a php value inside the fancybox window below, which isn’t quite happening.
<div style="display:none">
<div id="access-policy" style="width:600px; height:700px;">
<div style="position:relative; width:95%; height:360px;">
<p style="position:relative; float:left; margin-top:-9px;"><a href="javascript:void(0);" onclick="$.fancybox.close();">cerrar [x]</a></p>
<p>Gracias <span id="namePay2"> </span>,</p>
<?php
$value = $_POST['val'];
echo "I got your value! $value";
?>
Then this is the jquery with my new post attempt ($.post(‘register.php’, ‘val=’ + hname.val());_)
success: function (html) {
$.post('register.php', 'val=' + hname.val());
$('#namePay').val(hname.val() + " - Jumbo Tours");
var span = document.getElementById('namePay2');
span.firstChild.nodeValue = name.val();
$.fancybox({
content: $('#access-policy'),
modal: true
});
return false;
//} else alert('Sorry, unexpected error. Please try again later.');
}
The fancybox although on the register.php page isn’t picking up what Im posting, which I think is working finer, just im not connecting the two up.
what I am getting at the moment in fancybox is -
Notice: Undefined index: val in \\DATASTORE101\CSFWEBDATA$\ ourcheck\jumbotours\register.php on line 143 I got your value!
Resolved the notice, with below, but now need that value posted so I can use it
<?php
$value = "";
if(isset($_POST['val'])){ $value = $_POST['val'];
echo "I got your value! $value";
}
?>
Ok have moved on slightly, to below, but still I’m not getting the value to work.
<form action="process.php" method="post" id="formMain">
<label id="Hname"> Nombre del establecimiento:</label>
<input type="text" name="Hname" id="yourName" /> <span style="color:#f00;"> * </span>
<?php
$value = "";
if(isset($_POST['user'])){ $value = $_POST['user'];
echo "I got your value! $value";
}
?>
success: function (html) {
$.ajax({
type: "POST",
url: "register.php",
data: {user:$('input[name=Hname]').val()},
success: function(data){
alert('Items added');
},
error: function(e){
console.log(e.message);
}
});
$.fancybox({
content: $('#access-policy'),
modal: true
});
return false;
}
The frustrating thing is that I am getting the success alert (‘Items added’).
This is what its inside the fancybox pop up, which is called from the same page as the rest of the code above which is on register.php
<div style="display:none">
<div id="access-policy" style="width:600px; height:700px;">
<div style="position:relative; width:95%; height:360px;">
<p>Gracias <span id="namePay2"> </span>,</p>
<?php
$value = "";
if(isset($_POST['user'])){ $value = $_POST['user'];
echo "I got your value! $value";
}
?>
</div>
</div>
</div>