...

View Full Version : Using Numeric Data Collected From Forms



gwayne
02-28-2003, 05:23 AM
Hello,

I'm having a problem using a numeric data element submitted by my form. I'm checking for a numeric value, but it seems to be coming in blank. Is it necessary to convert the item to an integer?

*** This code doesn't work - Num_PPAC form item sets TNT:
If ((Request("Num_PPAC") <> "") And (isnumeric(Request("Num_PPAC")))) Then

TNT = CInt(Num_PPAC)

ReDim Temp_PPADCode(TNT)

If Request("GenCodes") <> "" Then
X = 1
Do while X <= TNT
RandStuff = RndStr(7,"123456789abcdefghijkmnpqrstuvwxyz")
Temp_PPADCode(X) = Request("PPAC_PREFIX") & RandStuff
X = X + 1
Loop
pMsg = "TNT&nbsp;=&nbsp;" & TNT
Session("STemp_PPADCode") = Temp_PPADCode

End If

*** This code does work - TNT set to 10:
If ((Request("Num_PPAC") <> "") And (isnumeric(Request("Num_PPAC")))) Then

TNT = 10

ReDim Temp_PPADCode(TNT)

If Request("GenCodes") <> "" Then
X = 1
Do while X <= TNT
RandStuff = RndStr(7,"123456789abcdefghijkmnpqrstuvwxyz")
Temp_PPADCode(X) = Request("PPAC_PREFIX") & RandStuff
X = X + 1
Loop
pMsg = "TNT&nbsp;=&nbsp;" & TNT
Session("STemp_PPADCode") = Temp_PPADCode

End If


Thanks.

glenngv
02-28-2003, 06:45 AM
this is a javascript forum and not an ASP forum. you should have posted in the right forum. :rolleyes:
Anyway, here's the answer.

if the item you request is used many times, it is advisable to put it in a variable. And it is also more efficient if you specify what request collection you are accessing rather than just specifying Request(item)

dim ppac
ppac = Request.Form("Num_PPAC") 'if method is POST
'ppac = Request.Querystring("Num_PPAC") 'if method is GET
If ppac <> "" And isnumeric(ppac) Then

TNT = CInt(ppac)
...

gwayne
02-28-2003, 10:23 PM
Hey Glenn,

I just wanted to say thanks for your help, and to let you know that now my code is working fine, plus I've learned more about ASP and forms.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum