Ciao a tutti vorrei capire meglio come recuperare i valori con jquery.
Nel mio caso ho una tabella così formata:
ora sto facendo una funzione drag and drop con aggiornamento dell'indice :il problema è che quando aggiorna devo recuperare i dati con questo comandoCodice:<script type="text/javascript" src="js/jquery.js"></script> <script type="text/javascript" src="js/jquery.tablednd.0.6.min.js"></script> <script type="text/javascript"> $(document).ready(function() { // Initialise the first table (as before) $("#table-1").tableDnD( { onDrop: function(table, row) { aggiorna(); } }); }); function aggiorna() { var index = 0 ; $("#table-1 tr").each(function(i){ i++; index=i; $(this).attr('id','row'+i); var currentVal = $(this).find('#gg').val(); var a="a"; var b="b"; var c="c"; var d="d"; var giorno = $(this).find('#gg').val(); $(this).html('<td style="width:15px; ">♦ </td><td align="right"><input type="text" value="'+i+'" size="1" style="width:15px; " readonly="readonly" name="indice[]"></td><td> <input type="text" value="gg" maxlength="2" size="2" style="width:30px; " value="'+giorno+'"name="giorno[]"> /<input type="text" value="mm" maxlength="2" size="2" style="width:30px; "name="mese[]"> / <input type="text" value="aaaa" maxlength="4" size="4" style="width:40px; "name="anno[]"> </td> <td><input type="text" maxlength="40" value="'+currentVal+'"size="30"name="descrizione[]"></td><td><input type= "checkbox" onclick= "des('+a+',1);" id= "a1" value="cd"name="darecassa[]"></td><td><input type= "checkbox" onclick= "des('+b+',1);" id= "b1" value="ca"name="averecassa[]"></td><td><input type= "checkbox" onclick= "des('+c+',1); "id= "c1" value="bd" name="darebanca[]"></td><td><input type= "checkbox" onclick= "des('+d+',1); "id= "d1" value="ba" name="averebanca[]"></td> <td><input type="text" maxlength="8" size="8" name="importo[]"></td> <td style="border:0px;"><a href="#" onclick="removeFormField($(this).parent());return false;"><img src="img/edit_remove.png" border=0></img></a></td>') }); }; //<td><input type="text" size="25" name="txt[]" id="txt'+i+'" value="'+currentVal+'"></td> function removeFormField(el) { $(el.parent()).remove(); aggiorna(); inizializza_tabella(); }; </script>
e dove c'è ****** non so che mettere per filtrare la ricerca.Codice:$(this).find('******').val();
l'html è questo :
Codice HTML:<TABLE BORDER="2" bordercolor="blue" bgcolor="#00CCFF"align="center" CELLPADDING="15"><TD> <font face="tekton pro cond" size="5 "> <table border="1" id="table-1"> <tr id="1"> <td style="width:15px; ">♦ </td> <td><input type="text" value="1" size="1" style="width:15px; " readonly="readonly" name="indice[]"></td> <td> <input type="text" id="gg"value="gg" maxlength="2" size="2" style="width:30px; " name="giorno[]"> / <input type="text" value="mm" maxlength="2" size="2" style="width:30px; "name="mese[]"> / <input type="text" value="aaaa" maxlength="4" size="4" style="width:40px; "name="anno[]"> </td> <td><input type="text" maxlength="40" size="30"name="descrizione[]"></td> <td><input type= "checkbox" onclick= "des('a',1);" id= "a1" value="cd"name="darecassa[]"></td> <td><input type= "checkbox" onclick= "des('b',1);" id= "b1" value="ca"name="averecassa[]"></td> <td><input type= "checkbox" onclick= "des('c',1); "id= "c1" value="bd" name="darebanca[]"></td> <td><input type= "checkbox" onclick= "des('d',1); "id= "d1" value="ba" name="averebanca[]"></td> <td><input type="text" maxlength="8" size="8" name="importo[]"></td> <td style="border:0px;" align="center"><a href="#" onclick="removeFormField($(this).parent());return false;"><img src="img/edit_remove.png" ></a></td> <tr id="2"> <td style="width:15px; ">♦ </td> <td><input type="text" value="2" size="1" style="width:15px; " readonly="readonly" name="indice[]"></td> <td> <input type="text" value="gg" maxlength="2" size="2" style="width:30px; " name="giorno[]"> / <input type="text" value="mm" maxlength="2" size="2" style="width:30px; "name="mese[]"> / <input type="text" value="aaaa" maxlength="4" size="4" style="width:40px; "name="anno[]"> </td> <td><input type="text" maxlength="40" size="30"name="descrizione[]"></td> <td><input type= "checkbox" onclick= "des('a',1);" id= "a1" value="cd"name="darecassa[]"></td> <td><input type= "checkbox" onclick= "des('b',1);" id= "b1" value="ca"name="averecassa[]"></td> <td><input type= "checkbox" onclick= "des('c',1); "id= "c1" value="bd" name="darebanca[]"></td> <td><input type= "checkbox" onclick= "des('d',1); "id= "d1" value="ba" name="averebanca[]"></td> <td><input type="text" maxlength="8" size="8" name="importo[]"></td> <td style="border:0px;" align="center"><a href="#" onclick="removeFormField($(this).parent());return false;"><img src="img/edit_remove.png" ></a></td> <tr id="3"> <td style="width:15px; ">♦ </td> <td><input type="text" value="3" size="1" style="width:15px; " readonly="readonly" name="indice[]"></td> <td> <input type="text" value="gg" maxlength="2" size="2" style="width:30px; " name="giorno[]"> / <input type="text" value="mm" maxlength="2" size="2" style="width:30px; "name="mese[]"> / <input type="text" value="aaaa" maxlength="4" size="4" style="width:40px; "name="anno[]"> </td> <td><input type="text" maxlength="40" size="30"name="descrizione[]"></td> <td><input type= "checkbox" onclick= "des('a',1);" id= "a1" value="cd"name="darecassa[]"></td> <td><input type= "checkbox" onclick= "des('b',1);" id= "b1" value="ca"name="averecassa[]"></td> <td><input type= "checkbox" onclick= "des('c',1); "id= "c1" value="bd" name="darebanca[]"></td> <td><input type= "checkbox" onclick= "des('d',1); "id= "d1" value="ba" name="averebanca[]"></td> <td><input type="text" maxlength="8" size="8" name="importo[]"></td> <td style="border:0px;"align="center"><a href="#" onclick="removeFormField($(this).parent());return false;"><img src="img/edit_remove.png" ></a></td> </tr> </div> </table> <input type="button" value="Aggiungi riga" onclick="accoda()"> <input type="button" value="Rimuovi riga" onclick="rimuovi()"> <br> <p><input type="submit" value="Invia"> <input type="reset" value="Annulla" ></p></td> </form> </table>

LinkBack URL
About LinkBacks
