JS擷取迴圈表格中input的值
請問我該如何擷取到滑鼠點擊的tr行input的值呢?
現在擷取到的是始終是第一條記錄。。。。。。。
JScript code
function popUserDetail(x){ var popUp = document.getElementById("popUserDetail"); var h = (x.rowIndex)*20; popUp.style.top= 25 + h + "px"; popUp.style.left="142px"; popUp.style.width="200px"; popUp.style.height="100px"; popUp.style.visibility="visible"; var customerId = document.getElementsByTagName("input")[0].value; alert (customerId); }
PHP code
while ($records = mysql_fetch_array($rows)) { $arr = ct($records['uniqueid']); $fileLastUploadTime = $arr[1]; print ' '.st($records['lastT'],$fileLastUploadTime).' '.$records['barName'].' '.$records['lastLogin'].' '.date("Y-m-d H:i:s",$arr[1]).' '.$records['endTM'].' '.$arr[0].' '.$records['version'].' '; } print ' | 客戶編碼: | |
| 客戶地址: | |
| 初次登陸: | 備份周期: |
| 聯絡QQ: | 聯絡電話: |
------解決方案--------------------
看看你這句是什嗎?
var customerId = document.getElementsByTagName("input")[0].value;
索引是0當然永遠是第一個。
改為:
var customerId = document.getElementsByTagName("input")[x.rowIndex].value;
Try It Again!
------解決方案--------------------
var customerId = document.getElementsByTagName("input")[0].value;寫錯了
------解決方案--------------------
探討