PHP

Moderators: None (Apply to moderate this forum)
Number of threads: 1847
Number of posts: 5013

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Sebnto values from calendar to another calendar Posted by thaypan on 17 May 2012 at 7:50 AM
Hello everybody, I would make sure that the numeric values ​​included in the file "index.php" will be sent to "report.php" and then can not be changed.


Thanks

Like this: http://thaypan.altervista.org/Time_T...Management.png

index.php

<script type="text/javascript">
        function somma_valori(form) {       
            var elementi = form.elements.length;
            var somma = 0;
            for(var i = 0; i < elementi; i++){
                if(form.elements[i].name != "invia") {
                    var valore = parseInt(form.elements[i].value);
                    if(isNaN(valore))
                        valore = 0;               
                    somma = somma + valore;
                }
            }
            document.getElementById('somma').innerHTML = somma
        }
    </script>
    <style type="text/css">
        table{
            font-family:Arial, Helvetica, sans-serif;
            font-size:12px;
            text-align:center;
            background-color:#F1F1F1;
        }
        .dom{
            background-color:#FF6600;
        }
        .sab{
            background-color: #FFFFCC;
        }
        .oggi{
            border-width:2px;
            border-color: #009900;
            border-style:solid;
            font-weight:bold;
        }
        .me{
            font-family:Arial, Helvetica, sans-serif;
            font-size:14px;
            font-weight:bold;
        }
    </style>
    <?php
    $month = date('m');
    $year = date('Y');
    $oggi = date("d") + 0;
    $giorni_settimana = array(1, "Lun", "Mar", "Mer", "Gio", "Ven", "Sab", "Dom");
    $mese = array('Gennaio', 'Febbraio', 'Marzo', 'Aprile', 'Maggio', 'Giugno', 'Luglio', 'Agosto', 'Settembre', 'Ottobre', 'Novembre', 'Dicembre');
    $time_primo_del_mese = mktime(0, 0, 0, $month, 1, $year);
    $primo_del_mese = date('w', $time_primo_del_mese);
    $giorni_nel_mese = cal_days_in_month(CAL_GREGORIAN, $month, $year);
    echo "<span class=\"me\">" . $mese[($month - 1)] . "</span>";


    echo "<table border='1'>";
    echo "<form action='reports.php' method='post'>";
    echo "<tr>";
    $g = $primo_del_mese;
    for ($i = 1; $i <= $giorni_nel_mese; $i++) {
        $classe = "";
        if ($giorni_settimana[$g] == "Dom") {
            $classe = " class=\"dom\"";
        } elseif ($giorni_settimana[$g] == "Sab") {
            $classe = " class=\"sab\"";
        }
        echo "<td $classe>" . $giorni_settimana[$g] . "</td>";
        if ($g == 7) {
            $g = 1;
        } else {
            $g++;
        }
    }
    echo "</tr>";
    echo "<tr>";
    for ($i = 1; $i <= $giorni_nel_mese; $i++) {
        $classe = "";
        if ($i == $oggi) {
            $classe = " class=\"oggi\"";
        }
        echo "<td $classe>$i</td>";
    }
    echo "</tr>";
    echo "<tr>";
    for ($i = 1; $i <= $giorni_nel_mese; $i++) {
        echo "<td><input type='text' onkeyup='somma_valori(this.form)' size='1' name='" . $year . "-" . $month . "-" . $i . "'/></td>\n";
    }
    echo "</tr>";
    echo "<tr>";
    echo "<td colspan='$i'>";
    echo "Totale : <span id='somma'>0</span> &nbsp;";
    echo "&nbsp;<input type='submit' name='invia' value='Invia'/>";
    echo "</td>";
    echo "</tr>";
    echo "</form>";
    echo "</table>";
    ?>


reports.php


<?php

    $month = date('m');
    $year = date('Y');

    $giorni_settimana = array(1, "Lun", "Mar", "Mer", "Gio", "Ven", "Sab", "Dom");

    $time_primo_del_mese = mktime(0, 0, 0, $month, 1, $year);
    $primo_del_mese = date('w', $time_primo_del_mese);

    $giorni_nel_mese = cal_days_in_month(CAL_GREGORIAN, $month, $year);

    echo "<table border='1'>";
    echo "<tr>";
    $g = $primo_del_mese;
    for ($i = 1; $i <= $giorni_nel_mese; $i++) {
        echo "<td>" . $giorni_settimana[$g] . "</td>";
        if ($g == 7) {
            $g = 1;
        } else {
            $g++;
        }
    }
    echo "</tr>";
    echo "<tr>";
    for ($i = 1; $i <= $giorni_nel_mese; $i++) {
        echo "<td>$i</td>";
    }
    echo "</tr>";
    echo "</table>";

    unset($_POST['invia']);
    foreach ($_POST as $key => $value) {
        (int) $value;

        if ($value != 0) {
            echo $key . "->" . $value . "<br/>";
        }
    }
    ?>




 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.