Results 1 to 5 of 5

Thread: Checkboxes

  1. #1
    Catherine Parks Guest

    Default Checkboxes

    I am creating a form with multiple checkboxes. Each checkbox is assigned a numerical value. For each box that is ‘checked’, I need to add those values into a ‘total’ variable. I have the code to assign the variables and determine if they are checked. Any suggestions on &#039totaling&#039 the values is appreciated. (I am using VBScript.)

  2. #2
    K.Zig Guest

    Default RE: Checkboxes

    This is some rather crude code but you should get the idea of what is going on and be able to apply to your application (I Hope).<BR><BR>FORM POSTING PAGE-<BR>&#060;html&#062;<BR>&#060;form action="whatever.asp" method="post"<BR>&#060;input type="checkbox" name="vhscall" value="ON"&#062;<BR>&#060;input type="checkbox" name="vhsrec" value="ON"&#062;<BR>&#060;/Form&#062;<BR>&#060;/html&#062;<BR><BR>-----------------------------------------------------<BR><BR>WHATEVER.ASP PAGE-<BR>&#060;%<BR>vhscall = Request.form("vhscall")<BR>vhsrec = Request.form("vhsrec")<BR><BR>if vhscall = "ON" then<BR>varnum1 = "597"<BR>end if<BR><BR>if vhsrec = "ON" then<BR>varnum2 = "798"<BR>end if<BR><BR>vartotal = varnum1 + varnum2<BR><BR>response.write vartotal<BR><BR>%&#062;<BR><BR>

  3. #3
    Catherine Parks Guest

    Default RE: Checkboxes - Almost worked

    The total variable works - thank you. However, it does not &#039sum&#039. For instance, using the example: <BR><BR>--- vartotal = varnum1 + varnum2 ---(where varnum1 is &#039 1&#039 and varnum2 is &#039 2&#039)<BR><BR>I will get &#039 12&#039 instead of &#039 3&#039. I haven&#039t seen a function that<BR>will sum in Asp -- any suggestions?<BR>Thanks!

  4. #4
    K.Zig Guest

    Default RE: Checkboxes - Almost worked

    I am having I think the same problem you are exept I am trying to use &#062;&#060; symbols to compare variables. This is what some people have told me to try, Maybe it will work for you <BR><BR>Say this was your variable - strnum<BR>Put this with it Cint()<BR>so your variables look like this - Cint(strnum)<BR><BR>Hope this helps in your application<BR><BR>Good Luck<BR>

  5. #5
    Catherine Parks Guest

    Default RE: Checkboxes - CInt

    I ended up using CDbl because I was getting an overflow error<BR>with CInt. Thanks for your help!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts