Question about forms

This is a discussion on "Question about forms" within the Classic ASP section. This forum, and the thread "Question about forms are both part of the Program Your Website category.


 Subscribe in a reader

Go Back   Webforumz.com > Main Forums > Program Your Website > Classic ASP

Notices




Closed Thread
 
LinkBack Thread Tools
  #1  
Old Sep 4th, 2003, 18:34
New Member
Join Date: Sep 2003
Location: USA
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Question about forms

Ok, bare with me, as I'm 100% newbie to asp.

I've got a series of items each item has itemName, itemDescription, and itemPrice. Let's say I have 8 of them. Ok, what I've done so far is created an array:

intMaxProduct = 9
intMaxArraySize = 3

Dim strParts2Darray( (intMaxProduct - 1), (intMaxArraySize - 1) )

strParts2Darray(0,0) = "Widgets"
strParts2Darray(0,1) = "This widget contains a wedge-shaped wedge."
strParts2Darray(0,2) = 1699.00

etc...

Now, the next thing I do is an attempt manipulate this array. So, along with doing that, I also create a table to display the contents of the array. The next step is to eventually, pull this information from a database... which will be my next set of questions :

If Request.Form("Submit") <> "" Then
For intProductCounter = 0 to ( intMaxProduct - 1 )
varFrmQty = "frmQty_" & intProductCounter
if EXECUTE(Request.Form(""" & varFrmQty & """)) > 0 Then
dblSubTotal = dblSubTotal + (strParts2Darray(intProductCounter,2) * EXECUTE(Request.Form(""" & varFrmQty & """)))
End If
Next
dblTax = CDbl(Request.Form("frmTax"))
dblShipping = CDbl(Request.Form("frmShipping"))
dblTotal = dblTax + dblShipping + dblSubTotal
End If

Response.Write "<form action=""howtobuy.asp"" method=""post"" name=""frmproduct"" id=""frmProduct"">"
Response.Write "<table border=""0"" width=""388"" cellpadding=""0"" cellspacing=""0"" class=""text"">"
Response.Write "<tr><th>Qty</th><th>Product</th><th>Description</th><th>Price( $USD )</th></tr>"
For intInnerCounter = 0 to ( intMaxProduct - 1 )
Response.Write "<tr>"
strfrmQty = "frmQty_" & intInnerCounter
Response.Write "<td><input name=""" & strfrmqty & """ type=""text"" id=""" & strfrmQty & """ value=""0"" size=""4"" maxlength=""4"" /></td>"
For intOutterCounter = 0 to ( intMaxArraySize - 1 )
If intOutterCounter = 1 Then
Response.Write "<td class=""text_sm"">" & strParts2Darray(intInnerCounter, intOutterCounter) & "</td>"
Else
Response.Write "<td>" & strParts2Darray(intInnerCounter, intOutterCounter) & "</td>"
End If
Next
Response.Write "</tr>"
Next
%>

Ok, after the brief background... here's my concern, all the tutorials I see that deal with forms, none of them produce it the way I do. They actually type out the the table and place all the info then use asp to grab all the elements. Even though, I'm creating the table programmitically, will i still be able to grab the elements? Is there a better way to do this?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!

  #2  
Old Sep 4th, 2003, 20:14
Rob's Avatar
Rob Rob is offline
Webforumz Founder
Join Date: Jul 2003
Location: Southern UK
Age: 34
Posts: 3,192
Blog Entries: 7
Thanks: 27
Thanked 23 Times in 20 Posts
I would definitly rewrite the initial part of that code to this:-
Code: Select all
IfRequest.Form("Submit")<>""Then
	ForintProductCounter=0to(intMaxProduct-1)
		varFrmQty="frmQty_"&intProductCounter
		ifRequest.Form(varFrmQty)>0Then
			dblSubTotal=dblSubTotal+(strParts2Darray(intProductCounter,2)*cInt(Request.Form(varFrmQty)
		EndIf
	Next

	dblTax=CDbl(Request.Form("frmTax"))
	dblShipping=CDbl(Request.Form("frmShipping"))
	dblTotal=dblTax+dblShipping+dblSubTotal
EndIf
__________________
Click the 'Thanks!' button if this post has helped you

Rob - Webforumz Founder
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
  #3  
Old Sep 5th, 2003, 16:23
New Member
Join Date: Sep 2003
Location: USA
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
ok, I've gotten things to work so far; however, after I calculate, my quanity for whatever item(s) being purchased returns to zero. Do I need to insert a varible there like, <%= dblQty_# %>?

Also, I can't seem to get it to print doubles, like "$5.00" or $5.50". It shows as "$5" or "$5.5"... any ideas?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
  #4  
Old Sep 5th, 2003, 18:26
Reputable Member
Join Date: Sep 2003
Location: USA
Posts: 112
Thanks: 0
Thanked 0 Times in 0 Posts
You have to use the FormatCurrency function. I use this page http://www.w3schools.com/vbscript/vb..._functions.asp a lot for a reference.

jakyra
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Closed Thread

Tags
question, forms

Thread Tools

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Forms crackafaza Web Page Design 3 Aug 13th, 2007 02:16
Slightly embarassing forms question:-) Michaeln Web Page Design 3 Feb 19th, 2007 14:01
forms mickc90 PHP Forum 3 Aug 1st, 2006 22:06
Quick, random question (Forms) SephirGaine PHP Forum 5 Jul 2nd, 2006 20:53
Help with forms ... Drysdale Web Page Design 3 Jun 9th, 2005 08:34


All times are GMT. The time now is 15:09.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42