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 6 of 6
  1. #1
    Regular Coder
    Join Date
    Aug 2011
    Posts
    101
    Thanks
    7
    Thanked 0 Times in 0 Posts

    Question automatic total is not working.. help

    The parameter A should display the sum of the remaining six fields. I did try adding that using the JAVA script that is mentioned in second code. The total should be display immediately after value is set for any of the text boxes. The text box gets the value using drop down menu. This procedure only works if I use the keyboard tab. If I use the mouse to select YES and No, then it will not display the total

    Code:
    
    <html>
    
        <head>
            <script type="text/javascript" src="javascript/addfunctions.js"></script>
            <script type="text/javascript">
                function enable1()
    
                {
                    document.audit_billing_IE.Para_A_A1_comment.disabled = false;
                    document.audit_billing_IE.Para_A_A1_score.value = 00;
    
                }
                function enable2()
    
                {
                    document.audit_billing_IE.Para_A_A2_comment.disabled = false;
                    document.audit_billing_IE.Para_A_A2_score.value = 00;
                }
    
                function enable3()
    
                {
                    document.audit_billing_IE.Para_A_A3_comment.disabled = false;
                    document.audit_billing_IE.Para_A_A3_score.value = 00;
                }
                function enable4()
    
                {
                    document.audit_billing_IE.Para_A_A4_comment.disabled = false;
                    document.audit_billing_IE.Para_A_A4_score.value = 00;
                }
    
                function enable5()
    
                {
                    document.audit_billing_IE.Para_A_A5_comment.disabled = false;
                    document.audit_billing_IE.Para_A_A5_score.value = 00;
                }
                function enable6()
    
                {
                    document.audit_billing_IE.Para_A_A6_comment.disabled = false;
                    document.audit_billing_IE.Para_A_A6_score.value = 00;
                }
                function disable1()
    
                {
                    document.audit_billing_IE.Para_A_A1_comment.disabled = true; 
                    document.audit_billing_IE.Para_A_A1_score.value = 10;
                }
    
                function disable2()
    
                {
                    document.audit_billing_IE.Para_A_A2_comment.disabled = true; 
                    document.audit_billing_IE.Para_A_A2_score.value = 10;
                }
                function disable3()
    
                {
                    document.audit_billing_IE.Para_A_A3_comment.disabled = true; 
                    document.audit_billing_IE.Para_A_A3_score.value = 10;
                }
                function disable4()
    
                {
                    document.audit_billing_IE.Para_A_A4_comment.disabled = true; 
                    document.audit_billing_IE.Para_A_A4_score.value = 10;
                }
                function disable5()
    
                {
                    document.audit_billing_IE.Para_A_A5_comment.disabled = true; 
                    document.audit_billing_IE.Para_A_A5_score.value = 10;
                }
                function disable6()
    
                {
                    document.audit_billing_IE.Para_A_A6_comment.disabled = true; 
                    document.audit_billing_IE.Para_A_A6_score.value = 10;
                }
    
                function na1()
                {
                    document.audit_billing_IE.Para_A_A1_comment.disabled = true; 
                    document.audit_billing_IE.Para_A_A1_score.value = 00;
                }
                function na2()
                {
                    document.audit_billing_IE.Para_A_A2_comment.disabled = true; 
                    document.audit_billing_IE.Para_A_A2_score.value = 00;
                }
    
                function na3()
                {
                    document.audit_billing_IE.Para_A_A3_comment.disabled = true; 
                    document.audit_billing_IE.Para_A_A3_score.value = 00;
                }
                function na4()
                {
                    document.audit_billing_IE.Para_A_A4_comment.disabled = true; 
                    document.audit_billing_IE.Para_A_A4_score.value = 00;
                }
    
                function na5()
                {
                    document.audit_billing_IE.Para_A_A5_comment.disabled = true; 
                    document.audit_billing_IE.Para_A_A5_score.value = 00;
                }
    
                function na6()
                {
                    document.audit_billing_IE.Para_A_A6_comment.disabled = true; 
                    document.audit_billing_IE.Para_A_A6_score.value = 00;
                }
    
    
    
                function changed1(el)
                {
                    var sel = el.options[el.selectedIndex];
                    if (sel.value == "Yes")disable1();
                    if (sel.value == "No")enable1();
                    if (sel.value == "Na")na1();
                }
    
                function changed2(el)
                {
                    var sel = el.options[el.selectedIndex];
                    if (sel.value == "Yes")disable2();
                    if (sel.value == "No")enable2();
                    if (sel.value == "Na")na2();
                }
                function changed3(el)
                {
                    var sel = el.options[el.selectedIndex];
                    if (sel.value == "Yes")disable3();
                    if (sel.value == "No")enable3();
                    if (sel.value == "Na")na3();
                }
    
                function changed4(el)
                {
                    var sel = el.options[el.selectedIndex];
                    if (sel.value == "Yes")disable4();
                    if (sel.value == "No")enable4();
                    if (sel.value == "Na")na4();
                }
                function changed5(el)
                {
                    var sel = el.options[el.selectedIndex];
                    if (sel.value == "Yes")disable5();
                    if (sel.value == "No")enable5();
                    if (sel.value == "Na")na5();
                }
                function changed6(el)
                {
                    var sel = el.options[el.selectedIndex];
                    if (sel.value == "Yes")disable6();
                    if (sel.value == "No")enable6();
                    if (sel.value == "Na")na6();
                }
                </script>
            </head>
    
            <body>
                <form  name="audit_billing_IE" method="POST" action="billing.php">
                    <table>
                        <tr>
                            <td> Parameter A </td> 
                            <td colspan='3'> <input type="text" name="product_name4" id="product_name4" /> </td>
                        </tr>
    
    
                        <tr>
                            <td> Procedure </td>
                            <td> 
                                <select name="Para_A_A1" id = "Para_A_A1" align="center" onchange="changed1(this)">
                                    <option value="s1"> Select</option>
                                    <option value="Yes"> Yes </option>
                                    <option value="No"> No </option>
                                    <option value="Na"> Na </option>
                                </select>
                            </td>
                            <td> 
                                <input type="text" name="Para_A_A1_comment" value="" disabled/>
                            </td>
    
                            <td align="center"> <input type="text" name="Para_A_A1_score" value="" onFocus="startCalc();" onBlur="stopCalc();"/>
                            </td>
                        </tr>
    
                        <tr>
                            <td> Days Calculation </td>
                            <td> 
                                <select name="Para_A_A2" id = "Para_A_A2" align="center" onchange="changed2(this)">
                                    <option value="s2"> Select</option>
                                    <option value="Yes"> Yes </option>
                                    <option value="No"> No </option>
                                    <option value="Na"> Na </option>
    
                                </select>
                            </td>
    
                            <td >
                                <input type="text" name="Para_A_A2_comment" value="" disabled/>
                            </td>
    
                            <td> <input type="text" name="Para_A_A2_score" id="Para_A_A2_score" value="" onFocus="startCalc();" onBlur="stopCalc();"/>
                            </td>
                        </tr>
    
                        <tr>
                            <td> request form </td>
                            <td> 
                                <select name="Para_A_A3" align="center" onchange="changed3(this)">
                                    <option value="s3"> Select</option>
                                    <option value="Yes"> Yes </option>
                                    <option value="No"> No </option>
                                    <option value="Na"> Na </option>
    
                                </select>
                            </td>
    
                            <td >
                                <input type="text" name="Para_A_A3_comment" value="" disabled/>
                            </td>
    
                            <td> <input type="text" name="Para_A_A3_score" id="Para_A_A3_score" value="" onFocus="startCalc();" onBlur="stopCalc();" />
                            </td>
                        </tr>
    
                        <tr>
                            <td> Case </td>
                            <td> 
                                <select name="Para_A_A4" align="center" onchange="changed4(this)">
                                    <option value="s4"> Select</option>
                                    <option value="Yes"> Yes </option>
                                    <option value="No"> No </option>
                                    <option value="Na"> Na </option>
    
                                </select>
                            </td>
    
                            <td >
                                <input type="text" name="Para_A_A4_comment" value="" disabled/>
                            </td>
    
                            <td> <input type="text" name="Para_A_A4_score" id="Para_A_A4_score" value="" onFocus="startCalc();" onBlur="stopCalc();"/>
                            </td>
                        </tr>
    
                        <tr>
                            <td> interaction </td>
                            <td> 
                                <select name="Para_A_A5" align="center" onchange="changed5(this)">
                                    <option value="s5"> Select</option>
                                    <option value="Yes"> Yes </option>
                                    <option value="No"> No </option>
                                    <option value="Na"> Na </option>
    
                                </select>
                            </td>
    
                            <td >
                                <input type="text" name="Para_A_A5_comment" value="" disabled/>
                            </td>
    
                            <td> <input type="text" name="Para_A_A5_score" id="Para_A_A5_score" value="" onFocus="startCalc();" onBlur="stopCalc();"/>
                            </td>
                        </tr>
    
                        <tr>
                            <td> MIS</td>
                            <td> 
                                <select name="Para_A_A6" align="center" onchange="changed6(this)">
                                    <option value="s6"> Select</option>
                                    <option value="Yes"> Yes </option>
                                    <option value="No"> No </option>
                                    <option value="Na"> Na </option>
    
                                </select>
                            </td>
    
                            <td >
                                <input type="text" name="Para_A_A6_comment" value="" disabled/>
                            </td>
    
                            <td> <input type="text" name="Para_A_A6_score" id="Para_A_A6_score" value="" onFocus="startCalc();" onBlur="stopCalc();"/>
                            </td>
                        </tr>
    
                    </table>
                </form> 
            </body>                 
        </html>


    Code:
    function startCalc(){
      interval = setInterval("calc()",1);
    }
    function calc(){
      one = document.audit_billing_IE.Para_A_A1_score.value;
      two = document.audit_billing_IE.Para_A_A2_score.value; 
      three = document.audit_billing_IE.Para_A_A3_score.value; 
      four = document.audit_billing_IE.Para_A_A4_score.value; 
      five = document.audit_billing_IE.Para_A_A5_score.value; 
      six = document.audit_billing_IE.Para_A_A6_score.value; 
      document.audit_billing_IE.product_name4.value = [(one * 1) + (two * 1) + (three * 1) + (four * 1) + (five * 1) + (six * 1)];
    }
    function stopCalc(){
      clearInterval(interval);
    }
    Last edited by naveendk.55; 08-30-2011 at 02:59 PM.

  • #2
    Senior Coder
    Join Date
    Jan 2011
    Location
    Missouri
    Posts
    4,094
    Thanks
    23
    Thanked 594 Times in 593 Posts
    When you manually use the dropdown you do not give focus to the input element
    <input type="text" name="Para_A_A1_score" value="" onFocus="startCalc();" onBlur="stopCalc();">

    Try having the dropdown call startCalc()

  • #3
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,919
    Thanks
    203
    Thanked 2,531 Times in 2,509 Posts
    Quote Originally Posted by manikah View Post
    Could you tell me where we get right tutorial about java.
    Java and Javascript are entirely different programming languages, in spite of the confusingly similar names. Rather like Austria and Australia!

    Have a look at www.w3schools.com

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.

  • #4
    Senior Coder
    Join Date
    Jan 2011
    Location
    Missouri
    Posts
    4,094
    Thanks
    23
    Thanked 594 Times in 593 Posts
    I have found it hard to get all the info about javascript in one place. It's just scattered all over the internet. But try this for help:
    http://docstore.mik.ua/orelly/webprog/jscript/index.htm

    a free O'relly book, online.

  • #5
    Regular Coder
    Join Date
    Aug 2011
    Posts
    101
    Thanks
    7
    Thanked 0 Times in 0 Posts
    Where exactly I need to use the startcalc() in dropdown? I didn't get your point.

  • #6
    Regular Coder
    Join Date
    Aug 2011
    Posts
    101
    Thanks
    7
    Thanked 0 Times in 0 Posts

    resolved

    that worked... I put the startcalc() in selection and it worked. Excellent!!

    Thank you all 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
    •