item[field]

On Mar 14, 9:46 am, Alain Roger <raf.n...@gmail.com> wrote:
> Hi,
>
> i have several html tags with some additional attributes like 'type' or
> 'abbr'. for example :
> <th id="col_1" class="ColumnHeader" align="center" abbr="language" type="
> editabletext" style="width: 130px;">Language</th>
>
> now i have a function which should fill the TD tag of another table based on
> the abbr attribute of my first table (like you can see the TH above).
> this function looks like that :
> $.getJSON("lg.php",{ start: 0, offset : 10 },
>         function(data)
>                 {
>                     $.each(data.records, function(i,item){
>
>                         var o = "<tr>";
>
>                         $("#frm_table th").each(function(j){
>
>                             var tp = $(this).attr("type");
>
>                             if (tp != null && tp != "")
>                             {
>                               switch (tp)
>                                 {
>                                   case 'selectrow':
>                                       o += "<td><input type=checkbox
> name='rec' value='" + item.id + "'></input></td>";
>                                             break;
>
>                                         case 'editabletext':
>                                             var field =
> $(this).attr("abbr");
>                                             o +=  "<td>" + item +"." + field
> + "</td>";
>                                             break;
>                                 }
>                             }
>                         });
>                         o += "</tr>";
>                         $("#data_grid").append(o);
>                     });
>
> now my problem is that i'm not able to retrieve the item.id or item.language
> of my JSON records when i do:
> o +=  "<td>" + item +"." + field + "</td>";
>
> i guess it's because it is taken as simple string concatenation and does not
> cast it as object.
> so how can i solve it ?
> thanks a lot.
>
> Alain

Reply via email to