SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Guru
    Join Date
    Oct 2011
    Posts
    658
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Auto calculate inside while loop

    Hi...
    I just want to know if it is possible to have an autocalculate in a textboxes inside while loop?and if it is possible how?..

    here is my code:

    Code:
    <html>
    <head>
    <style type="text/css">
    #fieldset_PS{
        position: relative;
        width: 20%;
    }
    </style>
    <link rel="stylesheet" type="text/css" href="kanban.css" /> 
    <script type="text/javascript">
      
    function display_PS(){
        document.loading_kanban.action="ParameterSettings.php";
        document.loading_kanban.submit();
    }
    function display_Kanban(){
        document.loading_kanban.action="kanban_report.php";
        document.loading_kanban.submit();
    }
    </script>
    </head>
     <?php
      error_reporting(0);
    $con = mysql_connect('localhost', 'root','');
    
    if (!$con) {
        echo 'failed';
        die();
    }
    
    mysql_select_db("mes", $con);
    
    
    
    ?>
    <form name="loading_kanban">
    <div id="main_button">
    <center>
    <!--<label style="margin-left: .9em; font-family: Arial, Helvetica, sans-serif; font-size: .7em;">Display Details:</label><input  onclick='showDetails(this);' id='chkDetail'   type='checkbox' checked='checked' value='wip'/>     -->
    <input type="button" name="parameter_settings" value="Parameter Settings" onclick="display_PS()">
    <input type="button" name="parameter_settings" value="Stock Requisition"> 
    <input type="button" name="parameter_settings" value="Kanban Report" onclick="display_Kanban()">
    </div>
    <div id="fieldset_PS">
    <fieldset>
    <legend>Parameter Settings</legend>
    </center>  
    <table border="1">
    <th>Compounds</th>
    <th>Max</th>
    <th>Min</th>
    <?php
    $sql = "SELECT PCODE FROM parameter_settings ORDER BY PCODE ASC";
    $result = mysql_query($sql, $con);
    while ($row = mysql_fetch_assoc($result)){
    echo "<tr>
            <td>$row[PCODE]</td>
            <td><input type = 'text' name = 'max_pcode' size = '10'></td>
            <td><input type = 'text' name = 'min_pcode' size = '10'></td>
            </tr>";
    }   
    ?>
    </fieldset>
    </table>
    </div>
    </form>
    </html>
    I have table : parameter settings and i have fields: PCODE, max, min

    PCODE has data:

    PXX
    PYY
    PZZ
    PAA
    PBB
    Total

    I just want to know how can I auto calculate the total max and total min and it will display in the textbox beside Total...

    Thank you

  2. #2
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,702
    Mentioned
    101 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by newphpcoder View Post
    I just want to know how can I auto calculate the total max and total min and it will display in the textbox beside Total
    When any of the fields that affect the total are update, that is when you would trigger a function that adds up all of the appropriate fields and updates the total value.

    Are you looking to create this yourself with some minor assistance from us to help you get on your way, or are you looking for someone to craft together a complete solution for you?
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  3. #3
    SitePoint Guru
    Join Date
    Oct 2011
    Posts
    658
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I need minor assistance because its new for me this kind of scenarion and I don't know if my logic is possible or should I seaprate the total fields in to different table?

    Thank you

  4. #4
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,702
    Mentioned
    101 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by newphpcoder View Post
    I need minor assistance because its new for me this kind of scenarion and I don't know if my logic is possible or should I seaprate the total fields in to different table?
    While you can make use of that PHP and Database code above, it's next to useless for the rest of us.
    Would you mind providing us instead with the HTML code that is rendered to the page itself, or link us to a web page showing what it does?
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  5. #5
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,702
    Mentioned
    101 Post(s)
    Tagged
    4 Thread(s)
    Thread seems to be continued at: Auto calculate conversion and display beside textbox
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript


Bookmarks

Posting Permissions

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