[jQuery] getting data using html attribute
Hi,
i have several html tags with some additional attributes like 'type' or 'abbr'. for example :
<span class="nodeLabelBox repTarget"><<span class="nodeTag">th</span><span class="nodeAttr editGroup"> <span class="nodeName editable">id</span>="<span class="nodeValue editable">col_1</span>"</span><span class="nodeAttr editGroup"> <span class="nodeName editable">class</span>="<span class="nodeValue editable">ColumnHeader</span>"</span><span class="nodeAttr editGroup"> <span class="nodeName editable">align</span>="<span class="nodeValue editable">center</span>"</span><span class="nodeAttr editGroup"> <span class="nodeName editable">abbr</span>="<span class="nodeValue editable">language</span>"</span><span class="nodeAttr editGroup"> <span class="nodeName editable">type</span>="<span class="nodeValue editable">editabletext</span>"</span><span class="nodeAttr editGroup"> <span class="nodeName editable">style</span>="<span class="nodeValue editable">width: 130px;</span>"</span><span class="nodeBracket editable insertBefore">></span><span class="nodeText editable">Language</span></<span class="nodeTag">th</span>>
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='" + <a href="http://item.id">item.id</a> + "'></input></td>";
break;
case 'editabletext':
var field = $(this).attr("abbr");
o += "<td>" + item +"." + field + "</td>";
break;
}
}
});
o += "</tr>";
$("#data_grid").append(o);
});<br clear="all">
</span>
now my problem is that i'm not able to retrieve the <a href="http://item.id">item.id</a> or item.language of my JSON records when i do:
<span class="nodeLabelBox repTarget">o += "<td>" + item +"." + field + "</td>";</span>
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