2011-10-19 45 views
0

我有這個JS:設置標籤的value屬性使用JSON不工作

$.getJSON('getMessageDetails.php', function (json) { 
    var uc = json[4]; 
    var uc_length = uc.length; 
    var firstPartLength = uc_length - 5; 
    var uc_1 = uc.substring(0, firstPartLength); 
    var uc_2 = uc.substr(-5, 3); 
    var uc_3 = 'RC'; 
    if (json[2] != old_id) 
    { 
     $("#td_id").text(json[2]); 
     $("#td_id_new").text(json[2]); 
     $("#td_subject").text(json[3]); 
     $("#span_1").text(uc_1); 
     $("#span_2").text(uc_2); 
     $("#span_3").text(uc_3); 
     old_id = json[2]; 
    }  
}); 

的話,我有我的PHP/HTML

if (count($row) > 0) 
{ 
    echo "<input type='hidden' id='td_id_new' value='".$new_id."'></input>"; 
    echo $new_id; 
    echo "<tr>";   
    echo '<td><a class="red_link" href="'.ADDRESS.'view_message.php?id='.$new_id.'"><span class="red_link" id="td_subject">'.$subject.'</span></a></td>'; 
    echo '<td><span id="span_1">'.$uniqueCode1.'</span><span id="span_2" class="pink_text">'.$uniqueCode2.'</span><span id="span_3">'.$uniqueCode3.'</span></td>'; 
    echo "</tr>"; 
    } 

我要的是通過我的JSON $來設置$ NEW_ID( 「#td_id_new」)文本(JSON [2]);

當我檢查元件的輸出也給出了$ NEW_ID爲0 ....我初始化它,而不是用新的ID一切(所有其他標籤)更新罰款的json

檢查元素:

<input xmlns="http://www.w3.org/1999/xhtml" type="hidden" id="td_id_new" value="0">7</input> 

我得到了上面的值屬性是7因此$ new_id是7但是仍然沒有在標籤中爲$ new_id ???

請幫忙嗎? 謝謝

回答

相關問題