E-junkie - We help you sell online
World Class Solution - Damon @ PayPal
Sell & promote your products Join affiliate programs offered by sellers Shop Community
  Google Custom Search

E-junkie Ecommerce Forums » E-junkie Discussions

Tag Cloud for this topic:

using if then statements in html thank you page



brynmyrddinemrys
member
Posts: 3


I am a fairly inexperienced, renegade programmer and know only the basics of javascript and php, so this may be a simple question...

I am trying to incorporate logical if-then statements to create a thank you page that reports a well-formatted customized invoice, reporting only the data applicable to each customer's purchase. In other words, the invoice for a free file download does not need to report the price or shipping address, whereas the invoice for a tangible good would report all this information.

I am more familiar with javascript, so I wrote myself a code in javascript to trigger events on the thank you page, based upon the order data - but I cannot seem to figure out how to get my javascript code to recognize this order data... here's a sample of my logic:

<script>
var gross = document.getElementById(gross);
if (gross==null)
{document.write("<b>FREE DOWNLOAD</b>")}
else
{document.write("<b>ORDER DETAILS</b>")}
</script>

of course, this doesn't work because I totally just pulled that .getElementById command out of the air... but I am beginning to wonder whether this kind of thing is possible using javascript or whether I will have to try php instead. or maybe I am just missing something simple.


#
POSTED ON: January 27, 2009 @ 20:19 GMT -7




brynmyrddinemrys
member
Posts: 3


After reading more into this issue, I understand I'm going to have to use a php function to parse my page for these variables. Could someone explain to me why this doesn't work?

<script type="text/javascript">
var gross = "<?php print $_GET['mc_gross']; ?>";
if (gross==null)
{document.write("<b>OUTPUT 1</b>")}
else
{document.write("<b>OUTPUT2</b>")}
</script>

The php print function is not returning any variables...


#
POSTED ON: January 27, 2009 @ 22:54 GMT -7




E-junkieChef
E-Junkie Crew
Posts: 922


E-junkie publishes your code "as it is". Browser can parse the client side code i.e. JavaScript but it can't parse PHP.

The only parsing E-junkie does to your code before publishing it is to replace "template variables" with their respective values.

So, you code should be -

<script type="text/javascript">
var gross = "[%total%]";
if (gross==null)
{document.write("<b>OUTPUT 1</b>")}
else
{document.write("<b>OUTPUT2</b>")}
</script>

PS: I am assuming your are using this code on "common" thank you page.

For the complete list of template variables that you can use in the thank you page, please see http://www.e-junkie.com/ej/help.customization.htm


#
POSTED ON: January 28, 2009 @ 00:31 GMT -7




brynmyrddinemrys
member
Posts: 3


Hi, thanks for your help! I thought I had tried that one already, but I was apparently mistaken. Everything is working perfectly now!


#
POSTED ON: January 28, 2009 @ 03:19 GMT -7


You must be logged in to make a post. Please click here to login.

PayPal Certified Integration Google Checkout Certified Integrattion 30 Day Money Back Guarantee Slam the Online Scam
 Share this page!