JS Form Help Needed

Discussion in 'Software' started by Jodi, Apr 13, 2005.

  1. Jodi

    Jodi Private First Class

    I need help with a Java Script Form please, I have 99.9% of it done, but I would like to find a way to simply "add" the number checked boxes and take that number and have it automatically go into a text field which reports on the screen as they are filling out the form.

    The form calculates a total already when the user enters that number them selves, but I would like to find a way to have that number entered for them as they are filling in the form.
    The form is located here
    The first section of the form where you see the check boxes Sunday and Monday, I would like those to calculate a running total of "reserved seats" that will go in the text field that is in the next section called CALCULATE YOUR TOTAL right next to "Total Seats Reserved "

    If anyone can help that would be great, I have worked long and hard on this on my own and now I am in need of help.

    THANK YOU ALL

    ~JO
    jo@yourpagetoday.com
     
  2. Jodi

    Jodi Private First Class

    Simplified

    For a very simple version of my question...click here
    Thanks everyone
    ~Jo
     
  3. Wookie

    Wookie Sergeant Major

    You need to add a property to the checkbox OnClick="JAVASCRIPT: myfunction()"


    when it is clicked it will call a function you make in the head, I would make the function check to see if the box is checked when it is clicked, if it is

    document.myform.textbox.text = document.myform.textbox.text + 1

    else
    document.myform.textbox.text = document.myform.textbox.text - 1



    or close to that, thats all off the top of my head.
     
  4. Jodi

    Jodi Private First Class

    I was thinking something like that as well, I appreciate your help I wil give it a shot
     
  5. Jodi

    Jodi Private First Class

    Seems pretty simple, and I understand the syntax of how it should work, but it still will not. Have a look at my script
    What am I doing wrong?
    click here view source

    Thanks again, I am sure It is something simple.
     
  6. Wookie

    Wookie Sergeant Major

    This should get you started

    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <title>Untitled Document</title>
    
    
    <SCRIPT LANGUAGE="JavaScript">
    function myfunction(){
    
    		var myint
    		myint = (+document.myform.reserved.value)
    		myint = myint + 1		 
    
    		document.myform.reserved.value = myint
    
    
    
    }
    
    </script>
    
    
    
    
    
    </head>
    
    <body>
    <p>Simplified: </p>
    <p>Who knows the script that can add the check boxes with a running total (as the form is being filled out) in the reserved box?</p>
    
    <form name="myform">
    
      <input name="Monday" type="checkbox" id="Monday" OnClick="myfunction();" value="checkbox">
      +1<br>
    
    
    
      <input name="reserved" type="text" size="2"> 
     </form>
    
    </body>
    
    </html>
    
    
    
     
  7. Jodi

    Jodi Private First Class

    Very Great!! Thank you!!
     
  8. Jodi

    Jodi Private First Class

    Just one thing, How do I get it to -1 when unchecked?
    :D
     
  9. Wookie

    Wookie Sergeant Major

    just check to see if its checked :)



    Code:
    <SCRIPT LANGUAGE="JavaScript">
    function myfunction(){
    		var myint
    		if(document.myform.Monday.checked)
    {
    
    		
    		myint = (+document.myform.reserved.value)
    		myint = myint + 1		 
    
    		document.myform.reserved.value = myint
    }
    else
    {
    myint = (+document.myform.reserved.value)
    		myint = myint - 1		 
    
    		document.myform.reserved.value = myint
    
    
    
    
    }
    
    
    
    }
    
    </script>
    
     
  10. Jodi

    Jodi Private First Class

    OH DUH, your the best, ok I got Now, thank you SOOOOO much, If I ask you anything else I will pay u by the hour LOL
    Thanks again!
     
  11. Wookie

    Wookie Sergeant Major

    well im being payed right now lol im at work its a very slow day.
     
  12. Jodi

    Jodi Private First Class

    Hi Again, my finished product is hereHave a look at how much you've helped.
    I have a lot more to work to do on it still....
    I am not working on getting this section :IF PAYING BY CREDIT CARD ENTER DISCOUNTED TOTAL HERE $
    and this section: First Time Member Promotion*
    Qualified New Members Only, Enter Final Discounted Total Here
    To also run into the total when checked, but that may take a while.
    Anyway, thanks again. I learned a lot with your help.
    ~Jo
     

MajorGeeks.Com Menu

Downloads All In One Tweaks \ Android \ Anti-Malware \ Anti-Virus \ Appearance \ Backup \ Browsers \ CD\DVD\Blu-Ray \ Covert Ops \ Drive Utilities \ Drivers \ Graphics \ Internet Tools \ Multimedia \ Networking \ Office Tools \ PC Games \ System Tools \ Mac/Apple/Ipad Downloads

Other News: Top Downloads \ News (Tech) \ Off Base (Other Websites News) \ Way Off Base (Offbeat Stories and Pics)

Social: Facebook \ YouTube \ Twitter \ Tumblr \ Pintrest \ RSS Feeds