ASP Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreASP Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old November 16th, 2003, 08:20 PM
ShyLoVe ShyLoVe is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Posts: 1 ShyLoVe User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Unhappy URGENT ASSISTANCE: Checkedboxes to access

i'm creating an order form for this small restaurant and it's gotta be datadriven, so i'm using access. i've got the menu items listed and the price and i've put in checkboxes next to each item for the customer to select which items they would like. i want to get the "checked" boxes and tell the database that's been selected and then through a query i want it to tell the customer what they have ordered(selected) and i'll be putting the results on another page

also, i've included how much of each item they would like (quantity), with a max of two characters, and i'd like to multiply the qty to the price and then tell the customer the total cost of the order.

i know it's a lot to ask, but please! if anyone can help, i'm desperately in need of assistance, i'm only a learning student and need to get this done in the next couple of days =) thanks a million in advance

Reply With Quote
  #2  
Old November 17th, 2003, 04:14 AM
LabRaTT's Avatar
LabRaTT LabRaTT is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Location: Boston, MA, USA
Posts: 23 LabRaTT User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
here is one way

ok i don't know if this is the cleanest way.... but it does work....



<%
ichoice = Request.QueryString("choice")
Select Case ichoice
Case "order"
%>
<table border="0" cellpadding="0" cellspacing="5">
<%
IF Request.Form("soup") = "on" Then
subtotal1 = session("soupprice") * request.form("soupamount")
Response.Write "<tr>"
Response.Write "<td>"
Response.Write "Soup"
Response.Write "</td>"
Response.Write "<td>&nbsp;&nbsp;&nbsp;"
Response.Write "$"
Response.Write formatNumber(subtotal1, 2)
Response.Write "</td>"
Response.Write "</tr>"
End IF

IF Request.Form("steak") = "on" Then
subtotal2 = session("steakprice") * request.form("steakamount")
Response.Write "<tr>"
Response.Write "<td>"
Response.Write "Steak"
Response.Write "</td>"
Response.Write "<td>&nbsp;&nbsp;&nbsp;"
Response.Write "$"
Response.Write formatNumber(subtotal2, 2)
Response.Write "</td>"
Response.Write "</tr>"
End IF

IF Request.Form("burger") = "on" Then
subtotal3 = session("burgerprice") * request.form("burgeramount")
Response.Write "<tr>"
Response.Write "<td>"
Response.Write "Burger"
Response.Write "</td>"
Response.Write "<td>&nbsp;&nbsp;&nbsp;"
Response.Write "$"
Response.Write formatNumber(subtotal3, 2)
Response.Write "</td>"
Response.Write "</tr>"
End IF

total = subtotal1 + subtotal2 + subtotal3
totalformated = formatNumber(total, 2)
%>
<tr>
<td colspan="2">Total = $&nbsp;<%=totalformated%></td>
</tr>
</table>
<%
Case Else
session("soupprice") = "3.50"
session("steakprice") = "15.78"
session("burgerprice") = "5.98"
%>
<form action="checkboxes.asp?choice=order" method="post">
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td><input type="Checkbox" name="soup"></td>
<td Rowspan="3">&nbsp;&nbsp;&nbsp;</td>
<td><input type="Text" name="soupamount" size="2" maxlength="2"></td>
<td Rowspan="3">&nbsp;&nbsp;&nbsp;</td>
<td>soup</td>
<td Rowspan="3">&nbsp;&nbsp;&nbsp;</td>
<td>$&nbsp;<%=session("soupprice")%></td>
</tr>
<tr>
<td><input type="Checkbox" name="steak"></td>
<td><input type="Text" name="steakamount" size="2" maxlength="2"></td>
<td>steak</td>
<td>$&nbsp;<%=session("steakprice")%></td>
</tr>
<tr>
<td><input type="Checkbox" name="burger"></td>
<td><input type="Text" name="burgeramount" size="2" maxlength="2"></td>
<td>burger</td>
<td>$&nbsp;<%=session("burgerprice")%></td>
</tr>
<tr>
<td colspan="7"><br><input type="Submit" value="Submit"></td>
</tr>
</table>
</form>
<%End Select%>

Reply With Quote
  #3  
Old November 17th, 2003, 04:10 PM
unclefu unclefu is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Posts: 120 unclefu User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 30 m 57 sec
Reputation Power: 5
i'm guessing you're getting all the records from the menu list table then looping through the recordset (in that loop is the code to put a checkbox on the page).

if all the checkboxes have the same name and the value for each checkbox is the item's id from the table then when you submit the form you'll get a comma-seperated list of all the values (only for those checkboxes which were checked)

so let's say you've got two checkboxes, both named "orderList", checkbox A has the value of "1", checkbox B has the value of "2".

if both are checked then submitted then either from the QueryString or Form collection you can get "orderList".

when you retrieve it the value will be "1,2"

you can then use the vbscript function Split() to split the list into an array.

orderList = request.form("orderList")

orderArray = Split(orderList, ",") 'split at comma character

for i = lbound(orderArray) to ubound(orderArray)
'code to retrieve that items name,price and do any math from access db
next

to make the qty boxes work name the qty text boxes with the item's id.

so checkbox A with it's value of 1 would have an accompanying text box for qty whos name is "1"

then as you itterate through the array you could do

request.form(orderArray(i))

heh, i'm not great at explaining things so if you'd like me to clear anything up i'd be glad to do so.


you can test the request.form(orderArray(i)) idea with this code:

<%
x = Split(request.querystring("c"), ",")

for i = lbound(x) to ubound(x)
y = request.querystring(x(i))
response.write y & "<br>" & vbCrLf
next
%>

then in the address bar of your browser:
whatever_file.asp?c=4,5,7&4=d&5=e&7=z

the output:
d
e
z

i'd be glad to give you sample code for your project that's much clearer and formatted well (if you'd like) - just email me or leave a reply here.

-- justin

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreASP Programming > URGENT ASSISTANCE: Checkedboxes to access


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway