E-junkie Ecommerce Forums » E-junkie Discussions
Tag Cloud for this topic:
accept-charset
action
apply
benefits
button
cart
class
client
code
com
company
coupon
default
developer
disable
discount
document
ecom
ejc
ejejc
field
form
function
input
javascript
key
listed
location
method
onclick
opened
option
page
paid
parentnode
post
protocol
return
share
src
target
text
type
url
utf-8
value
var
view
window
working
| |
| |
|
SimpleRain member Posts: 1 |
Hey all, I programmed this for a client, so I thought I would share it with the community. This is how you can apply a coupon via an input field and button rather than in the cart. This is useful when you want to change the text for the coupon box. You can see a working demo here: http://simplerain.com/e-junkie/ Here is the simple function: ---------------------------------------------------------------------- ----------------------------------- <script language="javascript" type="text/javascript"> <!-- function addcode(note){ var userInput = document.getElementById('userInput').value; document.url.action = document.url.action+'&discount_code='+userInput; document.getElementById('userInput').value = 'enter it here'; return EJEJC_lc(note); } function EJEJC_lc(th) { return false; } document.write("<scr"+"ipt src='" + document.location.protocol + "//www.e-junkie.com/ecom/box.js' type='text/javascript'></scr"+"ipt>"); function stopRKey(evt) { var evt = (evt) ? evt : ((event) ? event : null); var node = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null); if ((evt.keyCode == 13) && (node.type=="text")) {return false;} } document.onkeypress = stopRKey; // --> </script> <form name="url" action="https://www.e-junkie.com/ecom/gb.php?c=cart&cl=38825&ejc=2" target="ej_ejc" method="POST" accept-charset="UTF-8"> <input type="text" id="userInput" class="urlinput" value="enter it here" onfocus="if (this.value == 'enter it here') { this.value=''; }" onblur="if (this.value == '') { this.value='enter it here'; }" /> <input type="button" class="submitbutton" onclick="addcode(this.parentNode)" style="width: auto;" value="Apply Coupon" /> </form> ---------------------------------------------------------------------- ----------------------------------- The only thing you will need to change is this line: <form name="url" action="https://www.e-junkie.com/ecom/gb.php?c=cart&cl=38825&ejc=2" target="ej_ejc" method="POST" accept-charset="UTF-8"> You need the action url to match the URL found in your view cart button. For this to function I also had to disable the return key for the page otherwise a new window opened up if anyone hit enter on the input box. This function should just be plug and play for anyone who wants it. Hope it helps someone out since it's an option e-junkie should just provide as default, as it was a desire for my client. So they paid for it, and the community benefits. Just gives props to my company if you feel like it, otherwise enjoy. -Dovy Paukstys SimpleRain Studios http://simplerain.com/ # POSTED ON: October 23, 2008 @ 21:14 GMT -7 MODIFIED ON: October 23, 2008 @ 21:24 GMT -7 |
|
E-junkieChef E-Junkie Crew Posts: 936 |
Dovy, I love the way you've customized our solution .. will you be interested in getting listed in our developer directory? # POSTED ON: October 28, 2008 @ 12:42 GMT -7 |
You must be logged in to make a post. Please click here to login. | |






