Menu

java script not working

Oliver
2010-01-16
2013-06-03
  • Oliver

    Oliver - 2010-01-16

    I created a form on my own and the script below works fine.  When I tried to use it with the form generated with the SourceForge generator it will not sum the form entries.  I think the problem is related to the form name or field names.  I have tried every combination I can think of but nothing works.  Any help would be greatly appreciated.

    <div id="mainForm">
    <div id="formHeader">
    <h2 class="formInfo">Report Entry Form</h2>
    <p class="formInfo">Towing Report Entry Form</p>
    </div>
    <BR/>
    <!- begin form ->

    <form method=post enctype=multipart/form-data action=processor.php onSubmit="return validatePage1();"><ul class=mainForm id="mainForm_1"><input type=hidden  name=field_1 id=field_1 value="">

    <script type="text/javascript">
    function startCalc()
    {
    interval = setInterval("calc()",1);
    }
    function calc()
    {
    one = document.mainForm.field_24.value;
    two = document.mainForm.field_25.value;
    three = document.mainForm.field_26.value;
    four = document.mainForm.field_27.value;
    five = document.mainForm.field_28.value;
    six = document.mainForm.field_29.value;
    document.mainForm.field_30= (one * 1) + (two * 1) + (three * 1) + (four * 1) + (five * 1) + (six * 1);
    }
    function stopCalc()
    {
    clearInterval(interval);
    }

    </script>

    <li class="mainForm" id="fieldBox_24">
    <label class="formFieldQuestion">Towing Charge&nbsp;*&nbsp;<a class=info href=#><img src=imgs/tip_small.png border=0><span class=infobox>Enter the amount of the towing charge</span></a></label><input class=mainForm type=text name=field_24 id=field_24 size='20' value=''></li>

    <li class="mainForm" id="fieldBox_25">
    <label class="formFieldQuestion">Winching Charge&nbsp;<a class=info href=#><img src=imgs/tip_small.png border=0><span class=infobox>Enter the charge for winching</span></a></label><input class=mainForm type=text name=field_25 id=field_25 size='20' value=''></li>

    <li class="mainForm" id="fieldBox_26">
    <label class="formFieldQuestion">Labor Charge&nbsp;<a class=info href=#><img src=imgs/tip_small.png border=0><span class=infobox>Enter the amount of any labor charges</span></a></label><input class=mainForm type=text name=field_26 id=field_26 size='20' value=''></li>

    <li class="mainForm" id="fieldBox_27">
    <label class="formFieldQuestion">Storage Charge&nbsp;<a class=info href=#><img src=imgs/tip_small.png border=0><span class=infobox>Enter the total amount of the storage charge</span></a></label><input class=mainForm type=text name=field_27 id=field_27 size='20' value=''></li>

    <li class="mainForm" id="fieldBox_28">
    <label class="formFieldQuestion">2ND Towing Charge&nbsp;<a class=info href=#><img src=imgs/tip_small.png border=0><span class=infobox>Enter the charge for the 2nd tow</span></a></label><input class=mainForm type=text name=field_28 id=field_28 size='20' value=''></li>

    <li class="mainForm" id="fieldBox_29">
    <label class="formFieldQuestion">Other Charges&nbsp;<a class=info href=#><img src=imgs/tip_small.png border=0><span class=infobox>Enter the amount of any additional charges</span></a></label><input class=mainForm type=text name=field_29 id=field_29 size='20' value=''></li>

    <li class="mainForm" id="fieldBox_30">
    <label class="formFieldQuestion">Total Charges&nbsp;*&nbsp;<a class=info href=#><img src=imgs/tip_small.png border=0><span class=infobox>Enter total amount to be billed</span></a></label><input class=mainForm type=text name=field_30 id=field_30 size='20' value=''></li>

    <!- end of this page ->

     
  • gary odom

    gary odom - 2010-01-17

    Received your email on my personal email account? I believe you may have confused me with someone who knows what they are doing.  I can handle db and queries somewhat HTML with the aid of W3C, php with the books at my elbow and JS not at all.  Sorry I can't help, I truly wish I was informed enough that I could.

    Gcodom

     
  • Oliver

    Oliver - 2010-01-17

    After looking and looking I found that I missed onFocus="startCalc();" onBlur="stopCalc();" in the <input> statement.  I added it to all of the blocks i.e. 
    <li class="mainForm" id="fieldBox_24">
    <label class="formFieldQuestion">Towing Charge&nbsp;*&nbsp;<a class=info href=#><img src=imgs/tip_small.png border=0><span class=infobox>Enter the amount of the towing charge</span></a></label><input class=mainForm type=text name=field_24 id=field_24 size='20' value='' onFocus="startCalc();" onBlur="stopCalc();"></li> 

    It still don't work.

    Maybe I should just ask if there is a way to sum the blocks 24 thru 29 and put the results into block 30 ????????

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.