E-Junkie Forum http://www.e-junkie.com/bb/ E-Junkie Forum RSS en-us Copyright 2009, 19.5 Degrees. All rights reserved. webmaster@e-junkie.com webmaster@e-junkie.com Tue, 28 Oct 2008 19:42:30 GMT Sun, 22 Nov 2009 01:43:28 GMT 681 E-JUNKIE 5 E-Junkie Forum http://www.e-junkie.com/bb/ http://www.e-junkie.com/ej/logo.gif 290 104 Post #2 http://www.e-junkie.com/bb/topic/2944/pg/0#post8098 http://www.e-junkie.com/bb/topic/2944/pg/0#post8098 Tue, 28 Oct 2008 19:42:30 GMT E-junkie Discussions; E-junkieChef Post #1 http://www.e-junkie.com/bb/topic/2944/pg/0#post8098 http://www.e-junkie.com/bb/topic/2944/pg/0#post8098 Fri, 24 Oct 2008 04:14:37 GMT
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/]]>
E-junkie Discussions; SimpleRain