jquery - Unable to retrieve input value from within table -


i have table populated in way (i'm using grider jquery plugin)

<table border="0" id="table_reserved_price_list">     <tbody>         <tr class="noedit">             <th class="testclass" col="cod_products">codice prodotto</th>             <th class="testclass" col="products">prodotto</th>             <th class="testclass" col="cat_products">categoria</th>             <th class="testclass" col="brand">brand</th>             <th class="testclass" col="discount">sconto percentuale</th>                                                     </tr>         <tr>                                                         <td>                 <input type="text" onchange="ajax_showoptions(this,'get_code_prod',event)" onkeyup="ajax_showoptions(this,'get_code_prod',event)" style="width:60px;" value="" class="input-small input_cod_products" name="input_cod_products[0]">             </td>             <td>                 <input type="text" onchange="ajax_showoptions(this,'get_code_prod',event)" onkeyup="ajax_showoptions(this,'get_prod',event)" style="width:60px;" value="" class="input-small" name="input_products[0]">             </td>             <td>                 <input type="text" onkeyup="ajax_showoptions2(this,'get_cat_prod',event)" style="width:60px;" value="" class="input-small" name="input_cat_products[0]">             </td>             <td>                 <input type="text" onkeyup="ajax_showoptions2(this,'get_brand_prod',event)" value="" class="input-small" name="input_brand[0]">             </td>             <td>                 <input type="text" style="width:10px;" value="" class="input-small" name="input_discount1[0]">                 -                 <input type="text" style="width:10px;" value="" class="input-small" name="input_discount2[0]">                 -                 <input type="text" style="width:10px;" value="" class="input-small" name="input_discount3[0]">             </td>             <td>                 <a class="addrow" href="#"><img width="12px" border="0" src="icons/add.png"></a>                  <a class="delete" href="#"><img border="0" src="icons/delete.gif"></a>             </td>         </tr>         <tr>                                                         <td>                 <input type="text" onchange="ajax_showoptions(this,'get_code_prod',event)" onkeyup="ajax_showoptions(this,'get_code_prod',event)" style="width: 60px;" value="" class="input-small input_cod_products" name="input_cod_products[1]">             </td>             <td>                 <input type="text" onchange="ajax_showoptions(this,'get_code_prod',event)" onkeyup="ajax_showoptions(this,'get_prod',event)" style="width: 60px;" value="" class="input-small" name="input_products[1]">             </td>             <td>                 <input type="text" onkeyup="ajax_showoptions2(this,'get_cat_prod',event)" style="width: 60px;" value="" class="input-small" name="input_cat_products[1]">             </td>             <td>                 <input type="text" onkeyup="ajax_showoptions2(this,'get_brand_prod',event)" value="" class="input-small" name="input_brand[1]">             </td>             <td>                 <input type="text" style="width: 10px;" value="" class="input-small" name="input_discount1[1]">                 -                 <input type="text" style="width: 10px;" value="" class="input-small" name="input_discount2[1]">                 -                 <input type="text" style="width: 10px;" value="" class="input-small" name="input_discount3[1]">             </td>             <td>                 <a class="addrow" href="#"><img width="12px" border="0" src="icons/add.png"></a>                 <a class="delete" href="#"><img border="0" src="icons/delete.gif"></a>             </td>         </tr>                                             </tbody> </table> 

i've made script retrieve value (in case code of product) , put in input element (in case name of product)

if (!inputobj)     inputobj=this;    var tmpvalue = inputobj.innerhtml;  if (ajax_list_msie)     tmpvalue = inputobj.innertext; else     tmpvalue = inputobj.textcontent;  if (!tmpvalue)     tmpvalue = inputobj.innerhtml;  ajax_list_activeinput.value = tmpvalue;  if (!isnan(tmpvalue)) {     //we retrive code , put product name                     var url = ajax_list_externalfile + '?get_prod_name' + '=1&letters=' + tmpvalue;     var title = "";     $.post(url, {         title: title     },     function(data){         $('[name=input_products\\[0\\]]').val(data);     });   } 

unfortunally i'm not able name second row, gets value first row only. can me?

thanks

you like

retrieve value:

jquery('[name^=input_products]').each(function () {   console.log($(this).val()); //prints value each input }); 

set value

jquery('[name^=input_products]').each(function () {   $(this).val("abc!"); }); 

will select elements names starts "input_products..."

see documentation http://api.jquery.com/category/selectors/


Comments

Popular posts from this blog

delphi - How to convert bitmaps to video? -

jasper reports - Fixed header in Excel using JasperReports -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -