Forum Moderators: coopster
Yahoo allow to get the variables or some info from the confirmation page like price and other stuff.
In their help page it says that you can get some info from this:
<script language=javascript>
<!-- // variables containing order information
var orderSubTotal = 75.00;
var orderTotal = 100.00;
var orderNumber = nnn;
var numOfItems = 2;
var items = new Array('itemid1','itemid2','itemid3','itemid4','itemid5');
var ids = new Array('te');
var codes = new Array('345');
var qtys = new Array(5,2,1,1,1);
var price = new Array(15.12,2.00,1.00,2.12,1.50);
--> </script>
as follows I put my script at the confirmation:
<img width=1 height=1 src='http://www.mydomain.com/conversion.php?t=Sale&a=$price&w=$orderNumber'>
My question is how can I put the variable in my script.
Can somebody help me with this issue?
<img width=1 height=1 src='http://www.mydomain.com/conversion.php?t=Sale&a=$price&w=$orderNumber'>
And in your
conversion.phpscript you would do something like the following in your JavaScript:
<script language=javascript>
<!-- // variables containing order information
var orderSubTotal = 75.00;
var orderTotal = 100.00;
var orderNumber = <?php print $_GET['orderNumber'];?>;
var numOfItems = 2;
...
--> </script>
<img width=1 height=1 src='http://www.mydomain.com/conversion.php?t=Sale&a=$price&w=$orderNumber'>
I have tried several ways to call the variables in the image tag but none have worked yet.
These are the syntaxes that I have tried:
<img width=1 height=1 src='http://www.mydomain.com/conversion.php?t=Sale&a=$var price&w=$var orderNumber'>
<img width=1 height=1 src='http://www.mydomain.com/conversion.php?t=Sale&a=var price = new Array(15.12,2.00,1.00,2.12,1.50)&w=var orderNumber = nnn'>
How can I transfer these JavaScript variables to my PHP program?
Thanks.
echo "<SCRIPT LANGUAGE=\"JavaScript\" type=\"text/javascript\">\n";
echo "function myfunction(form) {\n";
echo "var total = 0;\n";
for ($i = 1; $i <= $num_rows; $i++) {
echo "var max$i = form.VARquantity$i.value;\n";
echo "var num$i = max$i * 1;\n";
echo "total = total + num$i;\n";
}
echo "document.Add1.icount.value = total;\n";
echo "}\n";
echo "</script>\n";
Now that I have the value of total (via icount) in my form, it's available to the rest of my script. I hope this helps.
For grins, here is the relevant form:
<form action="http://www.domain.net/" method="POST" name="Add1">
<input type="text" name="icount" size="2" value="0">
<input type="submit" name="I1" value="Continue" onClick="myfunction(this.form)">
</form>
Anyway, if you truly need to build the image on the client side you can do so by *rebuilding* the src attribute value:
<script type="text/javascript">
<!-- // variables containing order information
var orderNumber = 123
var price = 1.50
-->
</script>
</head>
<body>
<p>
<img width="150" height="150" id="myLink" src="">
<script type="text/javascript">
var url = 'http://www.example.com/conversion.php?'
url += 't=Sale&'
url += 'a=' + price + '&'
url += 'w=' + orderNumber
document.getElementById('myLink').src = url
</script>
</p>
Sorry, I just reply today because I'm kinda busy working on other projects.
The price was working but the order number doesn't. Do you think there is something missing in the order number?
<p>
<img width="150" height="150" id="myLink" src=""> <script type="text/javascript">
var url = 'http://www.example.com/conversion.php?'
url += 't=Sale&'
url += 'a=' + price + '&'
url += 'w=' + orderNumber
document.getElementById('myLink').src = url </script>
</p>