GoGreen PC Tune-Up™
Learn More

Insta-Install™
this is how ssl encrypt our websites
MTNCOMP | List View | Table View | myBlog (1767 Entries)
myBlog Home

Blog


ASP, VBScript, Javascript - Custom Order Material - Plastic Sheet

by Mountain Computers Inc., Publication Date: Saturday, February 23, 2019

View Count: 17046, Keywords: ASP, VB Script, Javascript, OLE-DB, MS Access, HTML, Custom Order, Hashtags: #ASP #VBScript #Javascript #OLE-DB #MSAccess #HTML #CustomOrder



this is a classic example of custom cut order for materials.
 
even some of the larger material companies do not have an asp, javascript, database driven working example that works pretty good. wish i still had this operational, but the company has moved on to different solutions if not any at all. this was done back in 2011.. and ran for 7 years successfully
 
here is the code... enjoy...  more to come...
 

--- p.asp ---

< %@ LANGUAGE="VBSCRIPT" % >
< %
   option explicit
   response.expires = 0
   if request.querystring("method") = "leaveadminmode" then
           session("un") = ""
       end if
      
   rem title transition variables
   dim t1, t2
   dim product_description, sheet_description, shoppingcart_total, sheet_style
   t1 = ""
   t2 = ""
  
   select case request.querystring("sheet_style")
   case "full_sheet"
       sheet_style= "full_sheet"
       sheet_description= "Full Sheet"
   case "cut_to_size"
       sheet_style= "cut_to_size"
       rem sheet_description = ""
       rem already set by RS datafield
   case else
          sheet_style= "full_sheet"
   end select
  
% >
<!--#include virtual="/inc/sqldsn.asp"-->
<!--#include virtual="/inc/sqltext.asp"-->

<html>

<head>

<title>your title</title>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<meta name="keywords" content="your description">

<meta name="description" content="your description">

<META NAME="ROBOTS" CONTENT="all, index, follow">

<META NAME="REVISIT-AFTER" CONTENT="15 days">

<META NAME="DISTRIBUTION" CONTENT="global">

<META NAME="COPYRIGHT" CONTENT="Copyright (c) year yourcompanyname. All rights reserved.">

<META NAME="AUTHOR" CONTENT="owner name">

<style type="text/css">

<!--

body {

    margin-left: 15px;

    margin-top: 15px;

    margin-right: 15px;

    margin-bottom: 15px;

}
a:link {
    color: #00129B;
    text-decoration: none;
}
a:visited {
    text-decoration: none;
    color: #00129B;
}
a:hover {
    text-decoration: underline;
    color: #FF0000;
}
a:active {
    text-decoration: none;
    color: #00129B;
}
.style2 {
    font-family: "Times New Roman", Times, serif;
    font-size: 13px;
    font-weight: bold;
}
.style3 {
    font-family: "Times New Roman", Times, serif;
    font-size: 15px;
}
.style4 {
    font-family: Verdana, Arial, Helvetica, sans-serif;
    font-weight: bold;
    color: #FF0000;
    font-size: 32px;
}
.style5 {font-size: 26px}

-->

</style></head>



<body bgcolor="#003399" text="#000000">

< % select case request.querystring("mode") % >

< % case "deleteconfirm" % >
< %

sql = "delete * from products_table"
sql = sql & " WHERE product_id=" & request.querystring("product_id") & " "
response.write (sql)
set rs = Conn.Execute(sql)
response.write vbcrlf

sql = "delete * from products_detail_table"
sql = sql & " WHERE product_id=" & request.querystring("product_id") & " "
response.write (sql)
set rs = Conn.Execute(sql)
response.redirect "p.asp"

% >

< % case "deletedetailconfirm" % >
< %

sql = "delete * from products_detail_table"
sql = sql & " WHERE product_id=" & request.querystring("product_id") & " AND subproduct_id="  & request.querystring("subproduct_id")
response.write (sql)
set rs = Conn.Execute(sql)
response.redirect "p.asp?product_id=" & request.querystring("product_id")

% >


< % case "deleteproduct" % >
< %
sql = "SELECT * FROM products_table p WHERE p.product_id=" & request.querystring("product_id") & " "
'response.write (sql)
set rs = Conn.Execute(sql)
% >
<form name="deleteproduct" method="POST" action="p.asp?mode=deleteconfirm&product_id=< %=request.querystring("product_id")% >">
<table bgcolor="white" border="0" width="640">
<tr>
    <td colspan="2"><h1><font face="Arial">Delete</font></h1></td>
</tr>
<tr>
    <td><font face="Arial">Product Description: </font><input name="product_description" type="text" size="50" maxsize="50" value='< %=getsqltext(rs("product_description"))% >'></td>
</tr>
<tr>
    <td><font face="Arial">Full Sheet Description: </font><input name="product_full_sheet_size" type="text" size="50" maxsize="50" value='< %=getsqltext(rs("product_full_sheet_size"))% >'></td>

</tr>
<tr>
    <td><font face="Arial">Sort Order: </font><input name="sort_order" type="text" size="5" maxsize="50" value="< %=rs("sort_order")% >"></td>
    <td><input type="Submit" value="Delete? Are you sure?"></td>
</tr>
<tr>
    <td>&nbsp;</td>
</tr>
</table>
</form>

< % case "edit" % >
< %
sql = "SELECT * FROM products_table p WHERE p.product_id=" & request.querystring("product_id") & " "
'response.write (sql)
set rs = Conn.Execute(sql)
% >
<form name="edit" method="POST" action="p.asp?mode=updatedescription&product_id=< %=request.querystring("product_id")% >">
<table bgcolor="white" border="0" width="640">
<tr>
    <td colspan="2"><h1><font face="Arial">Edit</font></h1></td>
</tr>
<tr>
    <td><font face="Arial">Product Description: </font><input name="product_description" type="text" size="50" maxsize="50" value='< %=getsqltext(rs("product_description"))% >'></td>
</tr>
<tr>
    <td><font face="Arial">Full Sheet Description: </font><input name="product_full_sheet_size" type="text" size="50" maxsize="50" value='< %=getsqltext(rs("product_full_sheet_size"))% >'></td>

</tr>
<tr>
    <td><font face="Arial">Sort Order: </font><input name="sort_order" type="text" size="5" maxsize="50" value="< %=rs("sort_order")% >"></td>
</tr>
<tr>
    <td><font face="Arial">Visible? </font><select name="active_status">
            <option value="< %=rs("active_status")% >" selected>< %=rs("active_status")% ></option>
        <option value="True">True</option>
        <option value="False">False</option>
    </td>
    <td><input type="Submit" value="Update"></td>
</tr>
<tr>
    <td>&nbsp;</td>
</tr>
</table>
</form>


< % case "editdetail" % >
< %
sql = "SELECT * FROM products_detail_table p WHERE p.product_id=" & request.querystring("product_id") & " AND subproduct_id =" & request.querystring("subproduct_id")
'response.write (sql)
set rs = Conn.Execute(sql)
% >
<form name="edit" method="POST" action="p.asp?mode=updateproductsdetail&product_id=< %=request.querystring("product_id")% >&subproduct_id=< %=request.querystring("subproduct_id")% >">
<table bgcolor="white" border="0" width="640">
<tr>
    <td colspan="2"><h1><font face="Arial">Edit Sub Product Detail</font></h1></td>
</tr>
<tr>
    <td><font face="Arial">Sub Product Description: </font><input name="subproduct_description" type="text" size="50" maxsize="50" value='< %=getsqltext(rs("subproduct_description"))% >'></td>
</tr>
<tr>
    <td><font face="Arial">Cut to Size $: </font><input name="cut_to_size" type="text" size="50" maxsize="50" value='< %=getsqltext(rs("cut_to_size"))% >'></td>
</tr>
<tr>
    <td><font face="Arial">Full Sheet $: </font><input name="full_sheet" type="text" size="50" maxsize="50" value='< %=getsqltext(rs("full_sheet"))% >'></td>
</tr>
<tr>
    <td><font face="Arial">Sort Order: </font><input name="sort_order" type="text" size="5" maxsize="50" value="< %=rs("sort_order")% >"></td>
</tr>
<tr>
    <td><font face="Arial">Visible? </font><select name="active_status">
            <option value="< %=rs("active_status")% >" selected>< %=rs("active_status")% ></option>
        <option value="True">True</option>
        <option value="False">False</option>
    </td>
    <td><input type="Submit" value="Update"></td>
</tr>
<tr>
    <td>&nbsp;</td>
</tr>
</table>
</form>


< % case "deletedetail" % >
< %
sql = "SELECT * FROM products_detail_table p WHERE p.product_id=" & request.querystring("product_id") & " AND subproduct_id =" & request.querystring("subproduct_id")
'response.write (sql)
set rs = Conn.Execute(sql)
% >
<form name="deletedetail" method="POST" action="p.asp?mode=deletedetailconfirm&product_id=< %=request.querystring("product_id")% >&subproduct_id=< %=request.querystring("subproduct_id")% >">
<table bgcolor="white" border="0" width="640">
<tr>
    <td colspan="2"><h1><font face="Arial">Delete Sub Product Detail</font></h1></td>
</tr>
<tr>
    <td><font face="Arial">Sub Product Description: </font><input name="subproduct_description" type="text" size="50" maxsize="50" value='< %=getsqltext(rs("subproduct_description"))% >'></td>
</tr>
<tr>
    <td><font face="Arial">Cut to Size $: </font><input name="cut_to_size" type="text" size="50" maxsize="50" value='< %=getsqltext(rs("cut_to_size"))% >'></td>
</tr>
<tr>
    <td><font face="Arial">Full Sheet $: </font><input name="full_sheet" type="text" size="50" maxsize="50" value='< %=getsqltext(rs("full_sheet"))% >'></td>
</tr>
<tr>
    <td><font face="Arial">Sort Order: </font><input name="sort_order" type="text" size="5" maxsize="50" value="< %=rs("sort_order")% >"></td>
</tr>
<tr>
    <td><font face="Arial">Visible? </font><select name="active_status">
            <option value="< %=rs("active_status")% >" selected>< %=rs("active_status")% ></option>
        <option value="True">True</option>
        <option value="False">False</option>
    </td>
    <td><input type="Submit" value="Delete? Are you sure?"></td>
</tr>
<tr>
    <td>&nbsp;</td>
</tr>
</table>
</form>


< % case "addsubproduct" % >
<form name="addsubproduct" method="POST" action="p.asp?mode=addproductsdetailconfirm&product_id=< %=request.querystring("product_id")% >">
<table bgcolor="white" border="0" width="640">
<tr>
    <td colspan="2"><h1><font face="Arial">Add Sub Product </font></h1></td>
</tr>
<tr>
    <td><font face="Arial">Sub Product Description: </font><input name="subproduct_description" type="text" size="50" maxsize="50" value=''></td>
</tr>
<tr>
    <td><font face="Arial">Cut to Size $: </font><input name="cut_to_size" type="text" size="50" maxsize="50" value='0.00'></td>
</tr>
<tr>
    <td><font face="Arial">Full Sheet $: </font><input name="full_sheet" type="text" size="50" maxsize="50" value='0.00'></td>
</tr>
<tr>
    <td><font face="Arial">Sort Order: </font><input name="sort_order" type="text" size="5" maxsize="50" value=""></td>
</tr>
<tr>
    <td><font face="Arial">Visible? </font><select name="active_status">
        <option value="True" selected>True</option>
        <option value="False">False</option>
    </td>
    <td><input type="Submit" value="Submit"></td>
</tr>
<tr>
    <td>&nbsp;</td>
</tr>
</table>
</form>



< % case "updateproductsdetail" % >
< %

sql = "update products_detail_table"
sql = sql & " set subproduct_description = '" & getsqltext(trim(request.form("subproduct_description"))) & "', "
sql = sql & " full_sheet = " & getsqltext(trim(request.form("full_sheet"))) & ", "
sql = sql & " cut_to_size = " & getsqltext(trim(request.form("cut_to_size"))) & ", "
sql = sql & " sort_order = " & getsqltext(trim(request.form("sort_order"))) & ", "
sql = sql & " active_status = " & getsqltext(trim(request.form("active_status"))) & " "
sql = sql & " WHERE product_id=" & request.querystring("product_id") & " and subproduct_id=" & request.querystring("subproduct_id")
response.write (sql)
set rs = Conn.Execute(sql)
response.redirect "p.asp?product_id=" & request.querystring("product_id")

% >

< % case "addproductsdetailconfirm" % >
< %

sql = "INSERT INTO products_detail_table "
sql = sql & " (product_id, subproduct_description, cut_to_size, full_sheet, sort_order, active_status ) "
sql = sql & " select "
sql = sql & request.querystring("product_id") & ", "
sql = sql & " '" & getsqltext(trim(request.form("subproduct_description"))) & "', "
sql = sql & " " & getsqltext(trim(request.form("cut_to_size"))) & ", "
sql = sql & " " & getsqltext(trim(request.form("full_sheet"))) & ", "
sql = sql & " " & getsqltext(trim(request.form("sort_order"))) & ", "
sql = sql & " " & getsqltext(trim(request.form("active_status"))) & " "

response.write (sql)
set rs = Conn.Execute(sql)
response.redirect "p.asp?product_id=" & request.querystring("product_id")

% >
< % case "addproductconfirm" % >
< %

sql = "INSERT INTO products_table "
sql = sql & " (product_description, product_full_sheet_size, sort_order, active_status ) "
sql = sql & " select "
sql = sql & " '" & getsqltext(trim(request.form("product_description"))) & "', "
sql = sql & " '" & getsqltext(trim(request.form("product_full_sheet_size"))) & "', "
sql = sql & " " & getsqltext(trim(request.form("sort_order"))) & ", "
sql = sql & " " & getsqltext(trim(request.form("active_status"))) & " "

response.write (sql) & vbCRLF
set rs = Conn.Execute(sql)

'get ID of product just inserted
sql =  " select product_id from products_table WHERE "
sql = sql & " product_description = '" & getsqltext(trim(request.form("product_description"))) & "' AND "
sql = sql & " product_full_sheet_size = '" & getsqltext(trim(request.form("product_full_sheet_size"))) & "' AND "
sql = sql & " sort_order = " & getsqltext(trim(request.form("sort_order"))) & " AND "
sql = sql & " active_status = " & getsqltext(trim(request.form("active_status"))) & " "

response.write (sql) & vbCRLF
set rs = Conn.Execute(sql)

dim new_ID
new_ID = rs("product_id")

'rem insert dummy record

sql = "INSERT INTO products_detail_table "
sql = sql & " (product_id, subproduct_description, cut_to_size, full_sheet, sort_order, active_status ) "
sql = sql & " select " & new_ID & ", "
sql = sql & " 'sample subproduct description', "
sql = sql & " 1.00, "
sql = sql & " 1.00, "
sql = sql & " 1, "
sql = sql & " " & getsqltext(trim(request.form("active_status"))) & " "
response.write (sql) & vbCRLF
set rs = Conn.Execute(sql)

response.redirect "p.asp"
% >

< % case "addproduct" % >

<form name="addproduct" method="POST" action="p.asp?mode=addproductconfirm">
<table bgcolor="white" border="0" width="640">
<tr>
    <td colspan="2"><h1><font face="Arial">Add Product</font></h1></td>
</tr>
<tr>
    <td><font face="Arial">Product Description: </font><input name="product_description" type="text" size="50" maxsize="50" value=''></td>
</tr>
<tr>
    <td><font face="Arial">Full Sheet Description: </font><input name="product_full_sheet_size" type="text" size="50" maxsize="50" value=''></td>

</tr>
<tr>
    <td><font face="Arial">Sort Order: </font><input name="sort_order" type="text" size="5" maxsize="50" value=""></td>
</tr>
<tr>
    <td><font face="Arial">Visible? </font><select name="active_status">
        <option value="True" selected>True</option>
        <option value="False">False</option>
    </td>
    <td><input type="Submit" value="Add Product"></td>
</tr>

<tr>
    <td>&nbsp;</td>
</tr>
</table>
</form>



< % case "updatedescription" % >
< %

sql = "update products_table"
sql = sql & " set product_description = '" & getsqltext(trim(request.form("product_description"))) & "', "
sql = sql & " product_full_sheet_size = '" & getsqltext(trim(request.form("product_full_sheet_size"))) & "', "
sql = sql & " sort_order = " & getsqltext(trim(request.form("sort_order"))) & ", "
sql = sql & " active_status = " & getsqltext(trim(request.form("active_status"))) & " "
sql = sql & " WHERE product_id=" & request.querystring("product_id") & " "
response.write (sql)
set rs = Conn.Execute(sql)
response.redirect "p.asp"

% >

< % case else % >

<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">

  <tr>

    <td width="31%" valign="top"><div align="center">
      <p style="margin-top: 0;"><img src="http://www.bulkdrive.com/yourimages_images/your_logo_2.gif" alt="your logo alt title" width="325" height="261"></p>
                    <div align="center"><font face="Arial, Helvetica, sans-serif" style="margin-top: 0; margin-bottom: 0;" align="center"><b>DISTRIBUTOR OF SHEET, ROD &amp; TUBE</b></font>
        </div>
            <p align="center" style="margin-top: 0; margin-bottom: 0;"><font face="Times New Roman, Times, serif"><b>If we don't have what you want in stock, <br>
        we will get it for you.</b></font></p>
            <p style="margin-top: 0; margin-bottom: 0;">.</p>
        <p align="center" style="margin-top: 0;"><img src="http://www.bulkdrive.com/yourcompany_images/visa72.gif" width="72" height="46">&nbsp; <img src="http://www.bulkdrive.com/yourcompany_images/mcard72.gif" width="72" height="47"></p>
        <p align="center" class="style3" style="margin-bottom: 0;"><strong>companyname</strong></p>
        <p class="style3" style="margin-top:0;margin-bottom:0;"><strong>street address<br>
  city state zip</strong></p>
        <p class="style3" style="margin-top:0;margin-bottom:0;"><strong>Phone #</strong></p>
        <p class="style3" style="margin-top:0;"><strong>Fax #</strong></p>
        <p class="style3" style="margin-bottom: 0;">Find our store using </p>
        <p class="style3" style="margin-top: 0; margin-bottom: 0;"><a href="http://www.mapquest.com/maps/map.adp?address=yourstreetaddress&zoom=11">  &nbsp;Mapquest</a>&nbsp; <a href="http://www.yellowpages.com/maps?address=yourstreetaddress">Yellow Pages</a> </p>
    </div></td>

    <td width="69%" colspan="2" valign="top"><blockquote>
      <p style="margin-bottom: 0;">&nbsp;</p>
<table width="97%" border="1">
  <tr valign="top">
    <td width="100%"><div align="center"><span class="style4">O<span class="style5">NLINE STORE</span></span></div></td>
  </tr>
< % if request.querystring("orderplaced") = "true" then % > 
    <tr valign="top">
    <td width="100%">
    <div align="center">
        <h3><font color="red">Your order has been placed. Order # < % = request.querystring("OrderID")% ></font></h3>
        </div></td>
  </tr>
< % end if % > 
  <tr valign="top">
    <td height="264">


< %
if request.querystring("product_id") <> "" then

    if session("un") = "admin" then
    sql = " SELECT products_table.active_status, products_detail_table.active_status, * "
    sql = sql & " FROM products_table INNER JOIN products_detail_table ON products_table.product_id = products_detail_table.product_id "
    sql = sql & " WHERE ( ((products_table.product_id)=" & request.querystring("product_id") & "))  "
    sql = sql & " ORDER BY products_table.sort_order, products_detail_table.sort_order; "
    else
    sql = " SELECT products_table.active_status, products_detail_table.active_status, * "
    sql = sql & " FROM products_table INNER JOIN products_detail_table ON products_table.product_id = products_detail_table.product_id "
    sql = sql & " WHERE ( ((products_table.active_status)=Yes) AND ((products_detail_table.active_status)=Yes) AND ((products_table.product_id)=" & request.querystring("product_id") & "))  "
    sql = sql & " ORDER BY products_table.sort_order, products_detail_table.sort_order; "
    end if
   
else
    if session("un") = "admin" then
        sql = " SELECT  * FROM products_table p ORDER BY sort_order"
    else
        sql = " SELECT  * FROM products_table p WHERE p.active_status = Yes ORDER BY sort_order"
    end if
   
end if

'response.write (sql)
set rs = Conn.Execute(sql)
% >

< % if request.querystring("product_id") <> "" then % >

<h1>< % product_description = rs("product_description") % >< % response.write(product_description)% ></h1>
<table border="0" cellpadding="3" cellspacing="0" >

    <tr>
    < % if request.querystring("sheet_style") = "cut_to_size" then % >
    <form name="cut_to_size_values">
    <td rowspan="8" valign="top" bgcolor="silver">
    <center>
    <b>Cut to Size<br>Dimensions</b>
    <br><br>
    Length: (inches)<br><br><input type="text" name="length" value="0" size="5">
    <br>
    Width: (inches)<br><br><input type="text" name="width" value="0"  size="5">
    <br><br><font size='-1'>Instructions:<br> Enter length, width,<br>and then enter quantity<br>of plastic thickness<br>then click Add to Cart</font>
    </center>
    </td>
    </form>
    < % end if % >
    <td bgcolor="silver"><b><center>Thickness</center></b></td>
    <td bgcolor="silver"><b><center>
    < % if request.querystring("sheet_style") = "full_sheet" then % >
    < % sheet_description = rs("product_full_sheet_size") % >
    < % response.write (sheet_description) % >
    < % else % >
    < % sheet_description = "Custom Cut To Size<br>Sq. Ft. Price" % >
    < % response.write (sheet_description) % >
    < % end if % >
    </center></b></td>
    <td bgcolor="silver"><b><center>Order Qty</center></b></td>
    <td bgcolor="silver"><b><center>Subtotal Price</center></b></td>
    <td bgcolor="silver"><b><center>&nbsp;</center></b></td>
    </tr>
   
    < %
    Do While Not rs.EOF
    % >
    < %
    t1 = rs("subproduct_description")
    if t1 <> t2 then
    % >

<form name="subproduct< %=rs("subproduct_id")% >" method="post" action="p.asp?mode=insert&product_id=< %=request.querystring("product_id")% >&sheet_style=< % = sheet_style % >">
<input type="hidden" name="sheet_description" value='< %=sheet_description% >')
    <tr>
   
    <td><p align="center">
     <input type="hidden" name="subproduct_id" value="< %=rs("subproduct_id") % >">
     <input type="hidden" name="subproduct_description" value='< %=rs("subproduct_description")% >'>
     < %=rs("subproduct_description") % >
     </td>

     <td><p align="center">
    < % if sheet_style = "full_sheet" then % >
     <input type="hidden" name="subproduct_price" value="< %=rs("full_sheet")% >">
     <input type="hidden" name="subproduct_long_description" value='Full Sheet (4x8, 32 sqft), < %=getsqltext(rs("subproduct_description"))% >'>
    <b>< %=formatcurrency(rs("full_sheet"),2)% ></b> x (4x8, 32 sqft) x <i>Order Qty</i>
     < % else % >
     <input type="hidden" name="subproduct_price" value="< %=rs("cut_to_size")% >">
    <input type="hidden" name="subproduct_long_description" value='Cut to Size, < %=getsqltext(rs("subproduct_description"))% >'>
    <b>< %=formatcurrency(rs("cut_to_size"),2)% ></b>
    < % end if % >
     </td>

    <td>
    <p align="center">
    < % if sheet_style = "full_sheet" then % >
    <input type="text" size="3" name="subproduct_quantity" value="0" OnChange="var myval; myval = (32 * document.subproduct< %=rs("subproduct_id")% >.subproduct_price.value) * document.subproduct< %=rs("subproduct_id")% >.subproduct_quantity.value; myval = Math.round(myval * 100) / 100; document.subproduct< %=rs("subproduct_id")% >.subproduct_extendedprice.value = '$' + myval.toFixed(2) ;">
    < % end if % >
    < % if sheet_style = "cut_to_size" then % >
    <input type="hidden" name="cut_to_size_length" size="3" value="0"><input type="hidden" name="cut_to_size_width" size="3" value="0">
    <input type="text" size="3" name="subproduct_quantity" value="0" OnChange="document.subproduct< %=rs("subproduct_id")% >.cut_to_size_length.value=document.cut_to_size_values.length.value;document.subproduct< %=rs("subproduct_id")% >.cut_to_size_width.value=document.cut_to_size_values.width.value;var myval; myval = (((document.cut_to_size_values.length.value * document.cut_to_size_values.width.value) / 144 )* document.subproduct< %=rs("subproduct_id")% >.subproduct_price.value) * document.subproduct< %=rs("subproduct_id")% >.subproduct_quantity.value; myval = Math.round(myval * 100) / 100; document.subproduct< %=rs("subproduct_id")% >.subproduct_extendedprice.value = '$' + myval.toFixed(2) ;">
    < % end if % >
    </td>
    <td>
    <p align="center">
    <input type="text" size="5" name="subproduct_extendedprice" value="0">
    </td>
    <td>
    <input type="Submit" name="Add" value="Add to Cart">
< % if session("un") = "admin" then % >
    &nbsp;
    <a alt="Edit" title="Edit" href="p.asp?mode=editdetail&product_id=< %=request.querystring("product_id")% >&subproduct_id=< %=rs("subproduct_id")% >"><font face="Arial" color="red"  size="-1">Edit</font></a>&nbsp;
    <a alt="Delete" title="Delete" href="p.asp?mode=deletedetail&product_id=< %=request.querystring("product_id")% >&subproduct_id=< %=rs("subproduct_id")% >"><font face="Arial" color="red"  size="-1">Delete</font></a>
< % end if % >
   
    </td>

      </tr>    
</form>

    < % end if % >

    </tr>
    < %
    t2 = t1
    rs.MoveNext
    Loop
    % >

<tr>
<td colspan="8">
< % if sheet_style = "cut_to_size" then % >
<i>Cut to Size Special Instructions and Note: If you have a cut to size special shape other than a rectangle or square, please call our office to request a quote.</i><br><br>
< % end if % >
< % if session("un") = "admin" then % >
    <br><center><a alt="Add Subproduct" title="Add Subproduct" href="p.asp?mode=addsubproduct&product_id=< %=request.querystring("product_id")% >"><font face="Arial" color="red" size="-1">Add Sub Product</font></a></center>
< % end if % ><br>
<i>Instructions: change the quantity field and then press your keyboard TAB key to update the Subtotal Price, and then click Add to Cart.</i>
</td>
</tr>


</table>

< % else % >
<br>
<ul>
<form name="products" method="post">
    <h2>Plastic Products</h2>
    < %
    Do While Not rs.EOF
    % >
    < %
    t1 = rs("product_description")
    if t1 <> t2 then
    % >
    <li><a href="p.asp?product_id=< %=rs("product_id")% >&sheet_style=< % =sheet_style % >">< %=rs("product_description")% ></a>
    < % if session("un") = "admin" then % >
    - <a href="p.asp?mode=edit&product_id=< %=rs("product_id")% >&sheet_style=< % =sheet_style % >"><font color="red" face="Arial" size="-1">Edit</font></a>&nbsp;
    - <a href="p.asp?mode=deleteproduct&product_id=< %=rs("product_id")% >&sheet_style=< % =sheet_style % >"><font color="red" face="Arial" size="-1">Delete</font></a>
    - <font face="Arial" size="-1" color="red">Visible (Active)?: < %=rs("active_status")% ></font>
    < % end if % >
     <br>
    < %
    end if
    % >
    < %
    t2 = t1
    rs.MoveNext
    Loop
    % >

</form>
</ul>

< % end if % >

</td>
  </tr>
< % if session("un") = "admin" and request.querystring("product_id") = "" then % >
    <tr>
    <td>
    <center><a alt="Add Subproduct" title="Add Subproduct" href="p.asp?mode=addproduct"><font color="red" face="Arial" size="-1">Add New Product</font></a></center>
    </td>
    </tr>
< % end if % >
 
 
</table>

< %
select case request.querystring("mode")

case "insert"

    sql = "insert into shoppingcart_table "
    sql = sql & " (session_id, product_id, subproduct_id, product_description, price_per_sq_foot, qty, extended_price, date_inserted) "
    if request.querystring("sheet_style") = "cut_to_size" then
        sql = sql & " values (" & Session.SessionID & ", " & request.querystring("product_id") & ", " & request.form("subproduct_id") & ", '" & product_description & ", " & request.form("full_sheet_description") & ", " & "Length:" & request.form("cut_to_size_length") & " Width:" & request.form("cut_to_size_width") & " " & getsqltext(request.form("subproduct_long_description")) & "', " & request.form("subproduct_price")  & ", " & request.form("subproduct_quantity") & ", '" & request.form("subproduct_extendedprice") & "', '" & now() & "') "
    else
        sql = sql & " values (" & Session.SessionID & ", " & request.querystring("product_id") & ", " & request.form("subproduct_id") & ", '" & product_description & ", " & request.form("full_sheet_description") & " " & getsqltext(request.form("subproduct_long_description")) & "', " & request.form("subproduct_price")  & ", " & request.form("subproduct_quantity") & ", '" & request.form("subproduct_extendedprice") & "', '" & now() & "') "
    end if
    'response.write (sql)
    set rs = Conn.Execute(sql)

case "delete"

    sql = "delete from shoppingcart_table "
    sql = sql & " where row_id =  " & request.querystring("row_id") & " AND session_id = " & Session.SessionID
    'response.write (sql)
    set rs = Conn.Execute(sql)

case "update"

case else

end select

% >

< % rem SID: response.write (Session.SessionID) % >
< %
sql = " SELECT * from shoppingcart_table where session_id = " & Session.SessionID
'response.write (sql)
set rs1 = Conn.Execute(sql)
if not rs1.EOF then
    response.write ("<p><p>")
    response.write ("<table border='0' cellpadding='0'>")
    response.write ("<tr><td rowspan='10'><img src='http://www.yourFQDN.com/images/shopping_cart_thumb.jpg'></td></tr>")
    response.write ("<tr><td bgcolor='Silver' colspan='8'><b>Your Shopping Cart</b></td></tr>")
    response.write ("<tr><td bgcolor='Silver'><b>Product</b></td><td bgcolor='Silver'><b>Price / Sq. Ft.</b></td><td bgcolor='Silver'><b>Order Quantity</b></td><td bgcolor='Silver'><b>Extended Price</b></td><td bgcolor='Silver'>&nbsp;</td></tr>")
    Do While Not rs1.EOF
    response.write ("<tr>")
    'response.write ("<td>" & rs1("row_id") & "-" & rs1("session_id") & " </td><td> " & rs1("product_id") & " </td><td> " & rs1("subproduct_id") & " </td> " )
    response.write ("<td> " & rs1("product_description") & " </td><td><p align='center'>" & formatcurrency(rs1("price_per_sq_foot"),2) & "</td><td><p align=center>" & rs1("qty") & " </td><td><p align=right>" & formatcurrency(rs1("extended_price"),2) & " </td> " )
    response.write ("<td> " & "<input type='button' name='Remove' value='Remove' OnClick=" & chr(34) & "window.open('p.asp?product_id=" & request.querystring("product_id") & "&mode=delete&row_id=" & rs1("row_id") & "', '_parent')" & chr(34) & "</td>"  )
    shoppingcart_total = shoppingcart_total + CCur(rs1("extended_price"))
    response.write ("</tr>")
    rs1.MoveNext
    Loop
    response.write ("<tr><td bgcolor='Silver' colspan='8'><p align='center'><b>Shopping Cart Total = " & formatcurrency(shoppingcart_total, 2) & "</b></td></tr>")
    response.write ("</table>")
else
    response.write ("<p>Your Shopping Cart is empty" & " - Note: Terms and Conditions apply.<hr>")
    shoppingcart_total = 0
end if

% >
<div align='center'>
<form name="test">
<input type=button name="homepage" value="Home page" OnClick="window.open('http://www.yourFQDN.com', '_parent')">
<input type=button name="productshomepage" value="Products Home page" OnClick="window.open('http://www.yourFQDN.com/p.asp', '_parent')">
< % select case sheet_style
case "full_sheet"
    response.write ("<input type='button' name='fullvscustombutton' value='Switch to Custom Size Pricing' OnClick=" & chr(34) & "window.open('p.asp?sheet_style=cut_to_size&product_id=" & request.querystring("product_id") & "', '_parent') " & chr(34) & "></form>" )
case "cut_to_size"
    response.write ("<input type='button' name='fullvscustombutton' value='Switch to Full Sheet Pricing' OnClick=" & chr(34) & "window.open('p.asp?sheet_style=full_sheet&product_id=" & request.querystring("product_id") & "', '_parent') " & chr(34) & "></form>" )
case else
    response.write ("<input type='button' name='fullvscustombutton' value='Switch to Custom Size Pricing' OnClick=" & chr(34) & "window.open('p.asp?sheet_style=cut_to_size&product_id=" & request.querystring("product_id") & "', '_parent') " & chr(34) & "></form>" )
end select
% >
< % if shoppingcart_total > 0 then % >
<input type=button name="CheckOut" value="Check Out" OnClick="window.open('http://www.yourFQDN.com/shoppingcart.asp?SessionID=< %=Session.SessionID% >', '_parent')">
< % end if % >
</form>
</center>
<table width="93%" border="0" align="left" cellpadding="10" cellspacing="0">
< % rem <!--#include virtual="yourcompany_navigation_menu.asp"--> % >
</table>
</blockquote>

    </td>

  </tr>

  <tr>

    <td colspan="3" valign="top"><blockquote style="margin-top: 0; margin-bottom: 0;">
      <p align="center" class="style2">Copyright (c) < %=year(date())% > your company or trade name. All rights reserved. <a href="yoursecretloginpage.asp">*</a>
      <br><a href="TermsandConditions.asp">Terms and Conditions</a>
      < % if session("un") = "admin" then % >
      <a href="adminpage.asp"><font face="Arial" size="-1" color="red">Admin Page</font></a>
      <a href="p.asp?method=leaveadminmode"><font face="Arial" size="-1" color="red">Leave Admin mode</font></a>
      < % end if % >
      </p>
      <p align="center" class="style2" style="margin-bottom: 0;">&nbsp;</p>
    </blockquote>       
    
    </td>
  </tr>

</table>

<div align="center"><br>

  &nbsp;

  <!--msnavigation-->

  <font color="#6699CC"></font></div>

< % end select % >

</body>
</html>


--- sqltext.asp ----

<SCRIPT LANGUAGE=VBScript RunAt=Server>
  REM This will get included by anyone who needs this functionality.
  REM That way we don't duplicate all over the place.

  REM Returns SQL number value. 0 if string is empty.
  Function GetFKValue(sText)
    Dim sSQLText

    if sText = "" or sText = " " then
      sSQLText = "NULL"
    else
      sSQLText =  sText
    end if

    GetFKValue = sSQLText
  End Function

  REM Function to double quote all single quotes found in a text field
  Function GetSQLText(sText)
    Dim bEnd
    Dim i
    Dim iLast
    Dim sSQLText

    bEnd = FALSE
    i = 1
    iLast = 1
    While Not bEnd
      i = InStr(iLast,sText,"'")
      if i > 0 then
        sSqlText = sSQLText & Mid(sText,iLast,i-iLast) & "''"
        iLast = i+1
      else
        sSqlText = sSQLText & Mid(sText,iLast)
        bEnd = TRUE   
      end if
    Wend
    GetSQLText = sSQLText
  End Function

  REM Returns SQL single quoted string. NULL if string is empty.
  Function GetSQLTextValue(sText)
    Dim sSQLText

    if sText = "" or sText = " " then
      sSQLText = "NULL"
    else
      sSQLText =  "'" & GetSQLText(sText) & "'"
    end if

    GetSQLTextValue = sSQLText
  End Function

  REM Returns SQL number value. 0 if string is empty.
  Function GetSQLNumberValue(sText)
    Dim sSQLText

    if sText = "" or sText = " " then
      sSQLText = "0"
    else
      sSQLText =  sText
    end if

    GetSQLNumberValue = sSQLText
  End Function
</SCRIPT>

-- sqldsn.asp ---

< %
response.buffer = true

Dim Conn
Dim connstr
Dim oConnection

Dim sql
Dim rs

Dim sql1
Dim rs1

Dim sql2
Dim rs2

Dim sql3
Dim rs3

Dim sql4
Dim rs4

Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Mode = 3
Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("/datafold/datafile.mdb") & ";"


const MIN_VALUE_INT = -2147483648

% >
 
shoppingcart_table
 
 
 
 products_table
 
 
 
products_detail_table
 
 
more to come...
 
 
 
 
 
 

if you found this article helpful, consider contributing $10, 20 an Andrew Jackson or so..to the author. more authors coming soon
FYI we use paypal or patreon, patreon has 3x the transaction fees, so we don't, not yet.

© 2024 myBlog™ v1.1 All rights reserved. We count views as reads, so let's not over think it.