지

[펌]체크박스 인풋 선택 활성 / 비활성화

· 2011-01-26 (수) 23:23:15 · 4403 · 1

<script type='text/javascript'>
if (typeof window.onload == 'function') {motorCheckbox_OL = window.onload;}
window.onload = function()
{
  if (window.motorCheckbox_OL) motorCheckbox_OL();
  var i, ca;
  ca = document.getElementsByName('motorCheckbox');
  for (i = 0; i < ca.length; ++i) {
    ca[i].onclick = motorCheckbox_click;
  }
}
function motorCheckbox_click()
{
  // find parent TR
  var tr = this.parentNode;
  while (tr && tr.nodeName.toLowerCase() != 'tr') {
    tr = tr.parentNode;
  }
  if (tr) {
    // get all inputs contained by TR
    var i, ia = tr.getElementsByTagName('input');
    for (i = 0; i < ia.length; ++i) {
      if (ia[i].type.toLowerCase() == 'text') { // filter out 'text' inputs
        ia[i].disabled = !this.checked;
      }
    }
  }
}
</script>

<table>
<tr>
    <td><input type="checkbox" name="motorCheckbox" value="<%=motor.getId()%>"></td>
    <td><input type="text" size="10" name="pris" disabled="true"></td>
    <td><input type="text" size="10" name="toppfart" disabled="true"></td>
    <td><input type="text" size="10" name="motorinstallasjon" disabled="true"></td>

</tr>
<tr>
    <td><input type="checkbox" name="motorCheckbox" value="<%=motor.getId()%>"></td>
    <td><input type="text" size="10" name="pris" disabled="true"></td>
    <td><input type="text" size="10" name="toppfart" disabled="true"></td>
    <td><input type="text" size="10" name="motorinstallasjon" disabled="true"></td>
</tr>
<tr>
    <td><input type="checkbox" name="motorCheckbox" value="<%=motor.getId()%>"></td>
    <td><input type="text" size="10" name="pris" disabled="true"></td>
    <td><input type="text" size="10" name="toppfart" disabled="true"></td>
    <td><input type="text" size="10" name="motorinstallasjon" disabled="true"></td>
    </td>
</tr>
</table>


필요하실분들 계실까봐 올려둡니다.
자주 사용하는 기능인데, 항상 까먹어서..-0- 이렇게 하나 퍼왔습니다-

|

댓글 1개

2011-02-26 (토) 20:58:20
좋은 정보네요 감사합니다
댓글을 작성하시려면 로그인이 필요합니다.

그누4 팁자료실

3,309건

그누보드4와 관련된 팁을 여러분들과 함께 공유하세요. 나누면 즐거움이 커집니다.

+
제목 글쓴이 날짜 조회
11-02-09 조회 4,877
11-02-09 조회 8,051
11-02-08 조회 5,314
11-02-06 조회 3,489
11-02-03 조회 5,721
11-02-03 조회 8,360
11-02-01 조회 3,582
11-01-29 조회 6,867
11-01-28 조회 5,077
11-01-28 조회 5,059
11-01-28 조회 3,749
11-01-27 조회 3,362
11-01-27 조회 3,877
11-01-26 조회 4,404
11-01-25 조회 5,095
11-01-18 조회 1만
11-01-17 조회 9,154
11-01-17 조회 7,532
11-01-16 조회 4,659
11-01-14 조회 6,092