Hi,
Below is code for a pop up offer on an order form. Previously, the offer was for two different items, the customer just clicked on the item they wanted, the popup would close & add the selection to the order. Now I want to change it so that the customer will have 4 items to choose from & they enter a quantity for each item.
This script puts a quantity of ONE and a specific item description on the order form, can you please tell me how I would change this script to pass the values that the customer inputs?
Thank you very much!
Main Page
Within <HEAD> Section::::::::::::::::::::::::::
<script language=”JavaScript” type=”text/javascript”>
<!– // Begins
function CalculateTotal(frm)
{
var total=0, price, qty, fld, nam;
for (var i=0; i < frm.elements.length; ++i)
{
fld = frm.elements[i];
nam = fld.name;
if (nam.substring(0,4) == “PROD”)
{
price = unescape(nam.substring(nam.indexOf(“_”,5) + 1, nam.length));
qty = unescape(fld.value);
if (qty > 0) total = total + (qty * price);
}
}
var price = Number(frm.elements[“SPECIAL_OFFER_PRICE”].price);
if (price > 0) {
qty = Number(frm.elements[“SPECIAL_OFFER_QTY”].value);
total = total + (qty
}
var price = Number(frm.elements[“SPECIAL_OFFER_PRICE2”].price);
if (price > 0) {
qty = Number(frm.elements[“SPECIAL_OFFER_QTY2”].value);
total = total + (qty * price);
}
frm.TOTAL.value = total;
}
function specialOffer(frm) {
if(frm.elements[“SPECIAL_OFFER_DESC”].value == “”
&& frm.elements[“SPECIAL_OFFER_DESC2”].value == “”) {
var myWin = window.open(“special_kw_new.htm”, “SPECIAL_OFFER”, “width=600,height=500”);
return false;
}
frm.submit();
return true;
}
function initialValue(frm) {
with (frm) {
elements[“SPECIAL_OFFER_QTY”].saveValue = “”;
elements[“SPECIAL_OFFER_DESC”].saveValue = “”;
elements[“SPECIAL_OFFER_PRICE”].saveValue = “”;
elements[“SPECIAL_OFFER_PRICE”].price = 0;
elements[“SPECIAL_OFFER_QTY2”].saveValue = “”;
elements[“SPECIAL_OFFER_DESC2”].saveValue = “”;
elements[“SPECIAL_OFFER_PRICE2”].saveValue = “”;
elements[“SPECIAL_OFFER_PRICE2”].price = 0;
}
return true;
}
function restoreValue(fld) {
fld.value = fld.saveValue;
return true;
}
// Ends –>
</SCRIPT>
******************************************************************
POP UP Code:
Within HEAD section:::::::::::::::::::::::::::::
<SCRIPT LANGUAGE=”JavaScript”>
<!– // Begins
parentWin = top.opener.top;
parentFrm = parentWin.document.forms[“ORDER_FORM”];
function First_One_Please() {
with (parentFrm) {
elements[“SPECIAL_OFFER_QTY”].value = “1”;
elements[“SPECIAL_OFFER_QTY”].saveValue = “1”;
elements[“SPECIAL_OFFER_DESC”].value = “item description”;
elements[“SPECIAL_OFFER_DESC”].saveValue = “item description”;
elements[“SPECIAL_OFFER_PRICE”].value = “$2.99”;
elements[“SPECIAL_OFFER_PRICE”].saveValue = “$2.99”;
elements[“SPECIAL_OFFER_PRICE”].price = 2.99;
}
}
function Second_One_Please() {
with (parentFrm) {
elements[“SPECIAL_OFFER_QTY2”].value = “1”;
elements[“SPECIAL_OFFER_QTY2”].saveValue = “1”;
elements[“SPECIAL_OFFER_DESC2”].value = “item2 description”;
elements[“SPECIAL_OFFER_DESC2”].saveValue = “item2 description”;
elements[“SPECIAL_OFFER_PRICE2”].value = “$2.99”;
elements[“SPECIAL_OFFER_PRICE2”].saveValue = “$2.99”;
elements[“SPECIAL_OFFER_PRICE2”].price = 2.99;
}
}
function OK_Thanks(opt) {
switch (opt) {
case “First”:
First_One_Please();
break;
case “Second”:
Second_One_Please();
break;
default:
First_One_Please();
Second_One_Please();
}
parentWin.CalculateTotal(parentFrm);
top.close();
}
function No_Thanks() {
parentFrm.submit();
top.close();
}
within PopUp <body> section::::::::::::::::::::::::::::::::::::::::::::
<TD><INPUT TYPE=TEXT NAME=”First” SIZE=1 MAXLENGTH=1></TD><TD>Item 1</TD>
<TD><INPUT TYPE=TEXT NAME=”second” SIZE=1 MAXLENGTH=1></TD><TD>Item 2</td>
<TD><INPUT TYPE=TEXT NAME=”Third” SIZE=1 MAXLENGTH=1></TD><TD>Item 3</TD>
<TD><INPUT TYPE=TEXT NAME=”Fourth” SIZE=1 MAXLENGTH=1></TD><TD>Item 4</td>
<br>
<a href=”javascript?K_Thanks(‘First, Second, Third, Fourth’)”>Add To My Order </a>
<a href=”javascript:No_Thanks();”>No Thanks. </a></center>
**********************
Thank you for any help!