/    Sign up×
Community /Pin to ProfileBookmark

My Cart is now showing total

Hi All,

I tried to calculate below scripts by function add() but they never show individual total value I purchased. Does something missing with my code?

<html>

<head>

<title>My Cart</title>

<STYLE TYPE=”text/css”>
select { border-bottom-style: dashed ;
border-bottom-color: yellow;
border-bottom-width: 1px;
color:blue;
font-family: verdana;
font-size:12;}

body{background-color:#ABDE12;}

H1{ font-family: verdana;
font-size:15;}
b,line{ font-family: verdana;
font-size:12;}

</STYLE>

<script language=javascript>

function add()
{

newWindow =window.open(“”, “newWin”, “toolbar=yes,location=yes,scrollbars=yes,resizable=yes,width=600,height=600” )
var line;

//If first option is selected the product price and quantity will be shown in sub windows.

line = “<left><table border=1> <tr><th><font face=verdana size=2>Products</th><th><font face=verdana size=2>Price S$</th><th><font face=verdana size=2>Quantity</th><th><font face=verdana size=2>Total21</th></tr>”;
if(document.productform.productlist.options[0].selected == true)
{
line = line + “<TR><TD><font face=verdana size=2>”+document.productform.productlist.options[0].value+”</TD><TD><INPUT TYPE = ‘button’ NAME = ‘txtPrice1’VALUE= 10></TD><TD><INPUT TYPE = ‘text’ NAME = ‘txtQty1’value=1 onblur= ‘txtTotal1.value = txtQty1.value * txtPrice1.value,txtTotal.value=parseInt(txtTotal.value)+parseInt(txtTotal1.value)’></TD><TD><INPUT TYPE=text readonly NAME=’txtTotal1′ SIZE=10 VALUE=0 onblur=’parseInt(txtTotal1.value)+20′></TD></TR>”;
};elseif(document.productform.productlist.options[1].selected == true)
{
line = line + “<TR><TD><font face=verdana size=2>”+document.productform.productlist.options[1].value+”</TD><TD><INPUT TYPE = ‘button’ NAME = ‘txtPrice2’ VALUE= 20></TD><TD><INPUT TYPE = ‘text’ NAME = ‘txtQty2’value=1 onblur= ‘txtTotal2.value = txtQty2.value * txtPrice2.value,txtTotal.value=parseInt(txtTotal.value)+parseInt(txtTotal2.value)’></TD><TD><INPUT TYPE=text readonly NAME=’txtTotal2′ SIZE=10 VALUE=0 onblur=’parseInt(txtTotal2.value)+12′></TD></TR>”;
};elseif(document.productform.productlist.options[2].selected == true)
{
line = line + “<TR><TD><font face=verdana size=2>”+document.productform.productlist.options[2].value+”</TD><TD><INPUT TYPE = ‘button’ NAME = ‘txtPrice3’ VALUE= 30></TD><TD><INPUT TYPE = ‘text’ NAME = ‘txtQty3’value=1 onblur= ‘txtTotal3.value = txtQty3.value * txtPrice3.value,txtTotal.value=parseInt(txtTotal.value)+parseInt(txtTotal3.value)’></TD><TD><INPUT TYPE=text readonly NAME=’txtTotal3′ SIZE=10 VALUE=0 onblur=’txtTotal3.value’></TD></TR>”;
};
if(document.productform.productlist.options[3].selected == true)
{
line = line + “<TR><TD><font face=verdana size=2>”+document.productform.productlist.options[3].value+”</TD><TD><INPUT TYPE = ‘button’ NAME = ‘txtPrice3’ VALUE= 40></TD><TD><INPUT TYPE = ‘text’ NAME = ‘txtQty4’value=1 onblur= ‘txtTotal4.value = txtQty4.value * txtPrice4.value,txtTotal.value=parseInt(txtTotal.value)+parseInt(txtTotal4.value)’></TD><TD><INPUT TYPE=text readonly NAME=’txtTotal4′ SIZE=10 VALUE=0 onblur=’txtTotal4.value’></TD></TR>”;
};
if(document.productform.productlist.options[4].selected == true)
{
line = line + “<TR><TD><font face=verdana size=2>”+document.productform.productlist.options[4].value+”</TD><TD><INPUT TYPE = ‘button’ NAME = ‘txtPrice5’ VALUE= 50></TD><TD><INPUT TYPE = ‘text’ NAME = ‘txtQty5’value=0 onblur= ‘txtTotal5.value = txtQty5.value * txtPrice5.value,txtTotal.value=parseInt(txtTotal.value)+parseInt(txtTotal5.value)’></TD><TD><INPUT TYPE=text readonly NAME=’txtTotal5′ SIZE=10 VALUE=0></TD></TR>”;
};
if(document.productform.productlist.options[5].selected == true)
{
line = line + “<TR><TD><font face=verdana size=2>”+document.productform.productlist.options[5].value+”</TD><TD><INPUT TYPE = ‘button’ NAME = ‘txtPrice6’ VALUE= 60></TD><TD><INPUT TYPE = ‘text’ NAME = ‘txtQty6’value=0 onblur= ‘txtTotal6.value = txtQty6.value * txtPrice6.value,txtTotal.value=parseInt(txtTotal.value)+parseInt(txtTotal6.value)’></TD><TD><INPUT TYPE=text readonly NAME=’txtTotal6′ SIZE=10 VALUE=0></TD></TR>”;
};

line = line + “<tr><td colspan=3 align=right ><font face=verdana size=2>TOTAL</td><td><INPUT TYPE =’button’ NAME = ‘txtTotal’ value=0 onblur=’txtTotal.value =parseInt(txtTotal.value)’></td>”;

line=line+”</table></left>”
newWindow.document.writeln(line);

}
</script>

</head>

<body>
<center>
<h1>BlueSky Pte Ltd</h1><br>
<b>Computer Accessories Catalog</b>
<form name=”productform”>
<select name=”productlist” size=6 multiple>
<option value=”WireLess Mouse”>Wireless Mouse</option>
<option value=”Network Card”>Network Card</option>
<option vaule=”keyboard(wireless)”>Keyboard Wireless</option>
<option value=”keyboard”> Wireless Keyboard</option>
<option value=”USB Hub”>USB Hub</option>
<option value=”ADSL Modem”>ADSL Modem</option>
</select>
<br><br>
<input type=button value=”Add To Busket” onclick=”add()” >

</form>

</center>
</body>

</html>

to post a comment
JavaScript

0Be the first to comment 😎

×

Success!

Help @FutureZone spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.23,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...