JS擷取迴圈表格中input的值,該怎麼處理

來源:互聯網
上載者:User
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;寫錯了
------解決方案--------------------
探討

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.