Ciao a tutti,
ho un problema su cui sto sbattendo la testa da troppi giorni![]()
![]()
![]()
Ho una pagina PHP che (collegandosi ad un DB MYSQL) crea una FORM con "$i" campi (i --> contatore):
echo "<form id=\"form2\" name=\"form2\" method=\"post\" action=\"homeOLA.php\" enctype=\"multipart/form-data\"> \n";
$sistema=$_SESSION['SISTEMA'];
$kit=$_SESSION['KIT'];
echo "
\n";
echo "<table width=\"1520px\" border=\"0\" align=\"center\"> \n";
echo "<tr> \n";
echo " <td bgcolor=\"#FF0000\"><span class=\"grande\"> Elenco AGESP di $sistema per il KIT $kit </span> \n";
echo "<table width=\"1520px\" id=\"tabellavalori\" align=\"center\" cellspacing=\"0\" summary=\"Elenco AGESP \"> \n";
echo "<tr align=\"center\"> \n";
echo " <th scope=\"col\" abbr=\"Configurations\" class=\"nobg\">AGESP</th> \n";
echo "<th scope=\"col\" abbr=\"In carico Back Office\">Titolo</th> \n";
echo "<th scope=\"col\" abbr=\"In carico Back Office\">Data Rilascio Documentazione Prevista</th> \n";
echo "<th scope=\"col\" abbr=\"In carico Back Office\">Data Rilascio Documentazione Effettiva</th> \n";
echo "<th scope=\"col\" abbr=\"In carico Back Office\">Data Rilascio SW Prevista</th> \n";
echo "<th scope=\"col\" abbr=\"In carico Back Office\">Data Rilascio SW Effettiva</th> \n";
echo "<th scope=\"col\" abbr=\"In carico Back Office\">Ultima Data Rilascio SW Effettiva</th> \n";
echo "<th scope=\"col\" abbr=\"In Corso\">Data Inizio Collaudo Prevista</th> \n";
echo "<th scope=\"col\" abbr=\"In Corso\">Data Inizio Collaudo Effettiva</th> \n";
echo "<th scope=\"col\" abbr=\"In Corso\">Data Fine Collaudo Prevista</th> \n";
echo "<th scope=\"col\" abbr=\"In Corso\">Data Fine Collaudo Effettiva</th> \n";
echo "<th scope=\"col\" abbr=\"In Corso\">Data Fine Esercizio Prevista</th> \n";
echo "<th scope=\"col\" abbr=\"In Corso\">Data Fine Esercizio Effettiva</th> \n";
echo "</tr> \n";
$sistema=$_SESSION['SISTEMA'];
$kit=$_SESSION['KIT'];
$select_agesp="select * FROM anagrafica_kit WHERE SISTEMA='".$sistema."' and KIT='".$kit."' order by cod_agesp ASC";
$query_agesp=$mysqli->query($select_agesp);
$i=1;
while ($row_agesp = $query_agesp->fetch_array(MYSQLI_NUM)) {
$agesp=$row_agesp[2];
$titolo=$row_agesp[3];
$data_doc_prevista=$row_agesp[11];
$data_doc_effettiva=$row_agesp[12];
$data_rilascio_sw_prevista=$row_agesp[13];
$data_rilascio_sw_effettiva=$row_agesp[14];
$data_inizio_coll_prevista=$row_agesp[15];
$data_inizio_coll_effettiva=$row_agesp[16];
$data_fine_coll_prevista=$row_agesp[17];
$data_fine_coll_effettiva=$row_agesp[18];
$data_esercizio_prevista=$row_agesp[19];
$data_esercizio_effettiva=$row_agesp[20];
$stato_pi=$row_agesp[21];
$ult_data_rilascio_sw_effettiva=$row_agesp[22];
echo "<tr align=\"center\"> \n";
echo "<th scope=\"row\" class=\"spec\">$agesp</th> \n";
echo "<td scope=\"row\" class=\"spec\">$titolo</td> \n";
if ($data_doc_prevista == '1970-01-01'){
logverificasistemi("DEBUG", "sono nell'if con data_doc_prevista settata al 70",$_SERVER['PHP_SELF'],__LINE__,$idsessione);
logverificasistemi("DEBUG", "data_doc_prevista --> $data_doc_prevista",$_SERVER['PHP_SELF'],__LINE__,$idsessione);
echo "<td width=\"108px\">N.D.</td> \n";
if ( $stato_pi != 'Definitivo' ){
echo "<td width=\"108px\">N.D.</td> \n";
}
}
else {
echo "<td width=\"108px\">$data_doc_prevista</td> \n";
if ( $stato_pi != 'Definitivo' ){ // verifico se lo stato della pi arrivata da TPORTAL rispetta il contratto
echo "<td scope=\"row\" class=\"spec\">$data_doc_effettiva</td> \n";
}
else {
echo "<td width=\"108px\"><input type=\"text\" name=\"datadoc$i\" title=\"$data_doc_effettiva\" value=\"$data_doc_effettiva\" style=\"width:106\" onclick=\"Calendar.show(this, '%Y/%m/%d', true)\" onfocus=\"Calendar.show(this, '%Y/%m/%d', true)\" onblur=\"Calendar.hide()\" /> \n";
}
}
echo "<td width=\"108px\">$data_rilascio_sw_prevista</td> \n";
echo "<td width=\"108px\"><input type=\"text\" name=\"data_ril_sw_eff_$i\" title=\"$data_rilascio_sw_effettiva\" value=\"$data_rilascio_sw_effettiva\" style=\"width:106\" onclick=\"Calendar.show(this, '%Y/%m/%d', true)\" onfocus=\"Calendar.show(this, '%Y/%m/%d', true)\" onblur=\"Calendar.hide()\" /> \n";
echo "<td width=\"108px\"><input type=\"text\" name=\"ult_data_rilascio_sw_effettiva_$i\" title=\"$ult_data_rilascio_sw_effettiva\" value=\"$ult_data_rilascio_sw_effettiva\" style=\"width:106\" onclick=\"Calendar.show(this, '%Y/%m/%d', true)\" onfocus=\"Calendar.show(this, '%Y/%m/%d', true)\" onblur=\"Calendar.hide()\" onChange=\"check_date(data_ril_sw_eff_$i, ult_data_rilascio_sw_effettiva_$i)\"/> \n";
echo "<td width=\"108px\">$data_inizio_coll_prevista</td> \n";
echo "<td width=\"108px\"><input type=\"text\" name=\"data_ini_coll_eff_$i\" title=\"$data_inizio_coll_effettiva\" value=\"$data_doc_effettiva\" style=\"width:106\" onclick=\"Calendar.show(this, '%Y/%m/%d', true)\" onfocus=\"Calendar.show(this, '%Y/%m/%d', true)\" onblur=\"Calendar.hide()\" /> \n";
echo "<td width=\"108px\">$data_fine_coll_prevista</td> \n";
echo "<td width=\"108px\"><input type=\"text\" name=\"data_fine_coll_eff_$i\" title=\"$data_fine_coll_effettiva\" value=\"$data_doc_effettiva\" style=\"width:106\" onclick=\"Calendar.show(this, '%Y/%m/%d', true)\" onfocus=\"Calendar.show(this, '%Y/%m/%d', true)\" onblur=\"Calendar.hide()\" /> \n";
echo "<td width=\"108px\">$data_esercizio_prevista</td> \n";
echo "<td width=\"108px\"><input type=\"text\" name=\"data_ese_eff_$i\" title=\"$data_esercizio_effettiva\" value=\"$data_doc_effettiva\" style=\"width:106\" onclick=\"Calendar.show(this, '%Y/%m/%d', true)\" onfocus=\"Calendar.show(this, '%Y/%m/%d', true)\" onblur=\"Calendar.hide()\" /> \n";
echo "</tr> \n";
$i=$i+1;
}
Cliccando i campi della text area mi si apre un calendario per inserire la data in formato YYYY/MM/DD
Ora io avrei necessità di effettuare un controllo sul campo "ult_data_rilascio_sw_effettiva_$i" nel momento in cui inserisco la data dal calendario. Il controllo che necessito è che il campo "ult_data_rilascio_sw_effettiva_$i" sia maggiore di "data_ril_sw_eff_$i". Ho provato ad inserire il seguente JS sul campo "ult_data_rilascio_sw_effettiva_$i" ma non sembra funzionare... :
<script type="text/javascript">
function check_date(data1,data2) {
//var data_iniziale = document.form2.data_ril_sw_eff_i.value;
//var data_finale = document.form2.ult_data_rilascio_sw_effettiva_i.va lue;
var arr1 = data1.split("-");
var arr2 = data2.split("/");
var d1 = new Date(arr1[2],arr1[1]-1,arr1[0]);
var d2 = new Date(arr2[2],arr2[1]-1,arr2[0]);
var r1 = d1.getTime();
var r2 = d2.getTime();
if (r1<=r2) alert("Il controllo ha avuto buon esito.");
else alert("La data di partenza è successiva a quella di arrivo!");
}
</script>
PER FAVORE AIUTOOOOO!!! Sono disperato!!![]()