Copy link to clipboard
Copied
<%
a = Request.Form("size")
b = Request.Form("lights")
c = Request.Form("logo")
d = Request.form("zone")
z = (a + b + c + d)
Response.Write z
%>
Z will only out put the values of a,b,c,d it will not add them together?
You can try it here...http://bigfootdesigns.com/web-dev/heliwagon/test.asp
thanks
B
Copy link to clipboard
Copied
myb it cause by your a,b,c,d data type. That why it didnt add the value.
Copy link to clipboard
Copied
What kind of answer is that? That does not help!
Copy link to clipboard
Copied
>myb it cause by your a,b,c,d data type. That why it didnt add the value.
VBScript has only one datatype - Variant. Form field values need to be converted to numeric before you can add them.
Copy link to clipboard
Copied
I can't get it to work. Can you please provide a working example of the code that I am trying to write. I am not a programmer! CInt willnot work I get an overflow error so I tried Int and I still get the following..
| Dolly | 500 |
| Lights | 100 |
| Logo | 100 |
| Zone | 600 |
| Total: 500100100600 |
a combination of the actual numbers not the sum of the number.
<%
Dim a, b, c, d, z
a = Request.Form ("size")
b = Request.Form ("lights")
c = Request.Form ("logo")
d = Request.Form ("zone")
z = (a + b + c + d)
Response.Write (Int(z))
thanks
B
Copy link to clipboard
Copied
You need to convert the values before you add them, not after:
a = cint (Request.Form ("size"))
etc....
Copy link to clipboard
Copied
Ok thanks that makes sense now and I have it working.
<%
a = cint (Request.Form ("size"))
b = cint (Request.Form ("lights"))
c = cint (Request.Form ("logo"))
d = cint (Request.Form ("zone"))
z = (a + b + c + d)
Response.Write z
%>
thanks
B
Copy link to clipboard
Copied
>VBScript has only one datatype - Variant. Form field values need to be converted to numeric before you can add them.
owh. okay thanks. im newbie in programming. thanks for the info.
>>>themachien : sorry that i cant help. im still new in programming
Copy link to clipboard
Copied
I can get the code to work if I replace the Request.Form with a number. It will total it correctly like this
<%
a = 4
b = 4
c = 4
d = 4
z = (a + b + c + d)
Response.Write z
%>
it will give me 16
but why will it only display the Request.Form values and not total them???
B
Copy link to clipboard
Copied
VBScript has only one datatype - Variant. Form fields are handled as text fields. In VBscript, the '+' operator serves as arithemetic additional as well as string concatenation. So if you want to use arithmatic operators on form fields, you must first convert them to numeric values. Use the cint() function.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now