Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Jul 2004
    Posts
    173
    Thanks
    0
    Thanked 0 Times in 0 Posts

    drop down boxes - add up to total? help please

    hi,

    basically i need to have a page with a few drop down boxes and text boxes containing numbers that add up to a total.

    for example

    drop down 1 - either not selected or selected and the value is 50
    drop down 2 - either not selected or selected and the value is 75
    text box - user types in a number i.e 25

    total box will then add up to 100.

    can someone please tell me how i can do this quickly, would very much appriciate it. thanks in advance
    Web and Business Development from Cornwall - Startbar.co.uk

  • #2
    Senior Coder
    Join Date
    Nov 2002
    Location
    North-East, UK
    Posts
    1,265
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Code:
    <form name="form1" method="post" action="">
      <select name="num1" id="num1">
        <option value="10" selected>10</option>
        <option value="20">20</option>
        <option value="30">30</option>
      </select>
      <select name="num2" id="num2">
        <option value="25">25</option>
        <option value="50" selected>50</option>
      </select>
      <input name="num3" type="text" id="num3" value="50">
      <input type="submit" name="Submit" value="Add it up">
    </form>
    <%
    If Len(Request.Form) > 0 Then
    	num1 = CInt(Request.Form("num1"))
    	num2 = CInt(Request.Form("num2"))
    	
    	If IsNumeric(Request.Form("num3")) Then
    		
    		num3 = CInt(Request.Form("num3"))
    		total = num1 + num2 + num3
    		Response.Write "Total: " & total
    	Else
    		Response.Write "Please enter a number"
    	End If
    End If
    %>


  •  

    Posting Permissions

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