2

I need to send some POST data using jquery-ui selectable in a form.

Checked object will be stored in my database after clicking "Aggiorna" button. I use the external Checked() function to preleve the last configuration by my database in order to dinamically choose the default selected items.

if(isset($_POST['Aggiorna']))    // button name
{
     global $Gruppo_Sensori,$Gruppo_Elettrovalvole,$id_GS,$id_GE, $G;
     // recupero le informazioni dal form
     for($i=0;$i<count($G); $i++)
     {
         if(isset($_POST[$G[$i]]))
         {
             // UPLOAD $_POST[$G[$i]] on my database
             unset($_POST[$G[$i]]);   // clear the $_POST data
         }
      }

echo "<form action='' method='POST' name='programmazione' id='programmazione'>";
echo"<table>";
    for($j=0;$j<7;$j++)
    {
            echo "<tr>";
            echo"<td>$G[$j]</td>";
            echo"<td>";
                for($i=0;$i<24;$i++)
                {
                     $k=$i+1;   //calcolo l'estremo superiore dell'intervallo
                     $value = array($j,$i,0,$j,$k,0);
                     $nome = $G[$j];
                     if(Checked($j,$i,0,$j,$k,0)) {
                         $checked = "checked";
                     } else {
                         $checked="";
                     }

                     echo "<input type='checkbox' name='$nome"."[]' value='". implode(',',$value). "' $checked/> $i:$k";                         
                }
                echo"</td>";
                echo "</tr>";
     }
echo"</table>";
echo "<tr><td></td><td><input type='submit' value='Aggiorna' name='Aggiorna'></input>

This code works, but now I would like to use jquery to do the same work, for a obviuos graphical reason. I have replaced the checkbox with

if(Checked($j,$i,$Minuto,$Giorno_Finale,$Ora_Finale,$Minuto_Finale))
{
    echo "<li class='ui-state-default ui-selected' id='$id'>$i</li>";             // selected
    $_POST[$nome][] = implode(',',$value); // adding items to $_POST in order to reinsert it on database
}
else
{
    echo "<li class='ui-state-default' id='$id'>$i</li>"; // unselected
}

I can't understand why it don't work An other problem will be to add other option than the defaults to $_POST using jquery

A demo is visible here under Programmazione tabs >> clicking on Clock images

User: guest, pass: guest

Thank you very much for your support

Federkun
  • 36,084
  • 8
  • 78
  • 90
user3450036
  • 85
  • 1
  • 2
  • 10
  • Probably my question should be sintetized in: "How can I send the array of the selected object of a jquery-ui using $_POST[] ?Thank you – user3450036 May 26 '15 at 18:11
  • If you submit the form there aren't input data to submit. – Federkun May 26 '15 at 18:29
  • @Leggendario thank you, so can you explain me how I can add the checked object in $_POST[] data? I'm doing it manually, but it seem to be wrong. I've spent a lot of time trying this, but is the first time I use j-query and I'm a little bit confused – user3450036 May 27 '15 at 07:20
  • 1
    See [this](https://jqueryui.com/button/#checkbox). You should also read [how (http) POST works](https://www.google.it/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=how+post+works+http). You can't set the `_POST` variable and find it again after sending the form. (per caso è un progetto per una tesina? Anche io avevo fatto qualcosa del genere :°D) – Federkun May 27 '15 at 08:16
  • Grazie @Leggendario , scusa se ti rispondo solo ora. Si, era il progetto dellala mia tesi di laurea, che adesso sto continuando per interesse personale. After a lot of attempts, I've now solved my problem using ajax. Now I manage all data using javascript and then I send them to a processing page in order to update my MySQL database. – user3450036 Jun 11 '15 at 14:55

0 Answers0