Skip to main content
Known Participant
February 8, 2011
Question

What is wrong with this ASP ???

  • February 8, 2011
  • 2 replies
  • 770 views

<%
    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

This topic has been closed for replies.

2 replies

Known Participant
February 8, 2011

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

Participating Frequently
February 8, 2011

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.

Participating Frequently
February 8, 2011

myb it cause by your a,b,c,d data type. That why it didnt add the value.

Known Participant
February 8, 2011

What kind of answer is that? That does not help!