0

Hi, everyone

I need little bit help related to creating Coupon script. Let me explain my idea, for example I have 100 coupons and I want to give each one to only one customer. And I want when one cupon is loaded next time it dosen't load.

Let say Coupon is "sale2017", so when buyer put his email address on first page to get cupon, upon submition he will be redirected to second page where javascript function starts and Coupon loads on second page and shows to customer, but I also want that this cupon never ever load again when next time other customer submit email.

Every time I want to show new cupon and also want to delete the loaded cupon so it never appear again.

I know how to create array with 100 cupons and also know how to show output on page through Javascript but I need function to do this. Please can you provide me that finction with code or can create a demo for me. Demo will be more helpful.

Hope to get help soon.

Regards,
Peace Coder

3
Contributors
4
Replies
25
Views
4 Weeks
Discussion Span
Last Post by pty
2

Not sure this is a Javascript function if for a real life site. You'd be better off storing coupons in a db and removing them as they are redeemed.

0

No basically coupons are stored on Amazon. We will put list on JS. Then if customer will get coupon and also buy from amazon that coupon will be removed. But if buyer get coupon but he don't buy product from amazon then coupon will be still available on amazon. So we will again update it and add it in our array.

0

Here I created one, but its not working.

Its showing nothing.

<!doctype html>
<html>
 <head>
  <title>Testing Coucpon</title>

  <script type="text/javascript">
  function coupon() {
    //CreatingArrays
    amazoncoupon = new Array (4);

    //Initializing Arrays
    amazoncoupon [0] = "sale2017";
    amazoncoupon [1] = "Guest";
    amazoncoupon [2] = "Welcome";
    amazoncoupon [3] = "Happy";

    return amazoncoupon.splice (0,1);
  }
 </script>
 </head>

 <body>
 <center>
 <h1> Hi </h1>
 <script>
 coupon();
 </script>

 </center>
 </body>
 </html>
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.