print data in onchange
<p>I want to print the data of one line of the DB, when varying the value of the select statement.</p>

<p>This is form </p>

<pre><code>&lt;div id=\"sendric\"&gt;
    &lt;form name=\"form_sendrich\" id=\"form_sendric\" method=\"post\" action=\"inc/assegna_cs.inc.php\"&gt;
    &lt;fieldset&gt;
    &lt;legend&gt;&lt;i&gt;&amp;nbsp;Assegnazione squadra intervento&lt;/i&gt;&lt;/legend&gt;

     &lt;b&gt;&lt;br/&gt;
       &lt;span&gt;&amp;nbsp;&amp;nbsp;Scegli la squadra pi&amp;ugrave; vicina al luogo dell'intervento. Vedi mappa&lt;/span&gt;
        &lt;br/&gt;&lt;br/&gt;
        Squadra &lt;select id=\"sel_cs\"&gt;");
                $i=0;
                while($i&lt;$contcs){
                    print("&lt;option name=\"id_cs\" value=\"".$tabcaposquadra[$i]['id']."\"&gt;".$tabcaposquadra[$i]['sede']."&lt;/option&gt;");
                    $i++;
                }
        print("&lt;/select&gt;
        &lt;div id=\"datisquadra\"&gt;&lt;/div&gt;   
        &lt;input type=\"hidden\" value=\"".$idrich."\"&gt;
        &lt;input type=\"submit\" /&gt;
        &lt;/fieldset&gt;
    &lt;/form&gt;
</code></pre>

<p></p>

<p>this is JS with Jquery, which arises from the value of the select and send to the php page</p>

<pre><code>    // Visualizzazione dati sull'onchange della select (delle squadre presenti)
$("#sel_cs").onchange(function(){
     var valueID=$("#sel_cs").val();
     $.ajax({
        type: "POST",
        url: "inc/vedisquadra.inc.php",
        data: "id_cs="+valueID,
        success: function(msg){
                     $("#datisquadra").html(msg);
             },
        error: function(msg){
                 $("#datisquadra").html(msg);
             },
        beforeSend:function(){
                     $("#datisquadra").html("&lt;img hspace='84' src='images/loading.gif' alt='Loading...'  width='32' height='32'&gt;");
             }
     });
});
</code></pre>

<p>this is script php to print data in asincrono, i do not think there are problems with this page</p>

<pre><code>$id_ut=$_POST['id_cs'];

    $sql = "SELECT * FROM `utenti` WHERE `id`=".$id_ut;//query nel db 
 $dati=mysql_query($sql);
 if (!$dati) {
    echo "Query non eseguita correttamente sul DB($sql): ".mysql_error();
    exit;
 }
  $row=mysql_fetch_array($dati, MYSQL_ASSOC);
 $cs_nome=$row['nome'];
 $cs_cognome=$row['cognome'];
 $cs_mail=$row['mail'];
 $cs_sede=$row['sede'];
 $cs_tool=$row['attrezzature'];


$msg="&lt;br/&gt;
    &lt;b&gt;Caposquadra: &lt;/b&gt;".$cs_nome." ".$cs_cognome."&lt;br/&gt;
    &lt;b&gt;E-mail: &lt;/b&gt;".$cs_mail."&lt;br/&gt;
    &lt;b&gt;Sede: &lt;/b&gt;.".$cs_sede."&lt;/br&gt;
    &lt;b&gt;Attrezzatura: &lt;/b&gt;".$cs_tool;

echo $msg;
</code></pre>
