2013-10-29 3 views
0

필자는 여기에 텍스트 상자 oncheck 체크 박스 배열을 사용

내 코드는 ... 해당 체크 박스가 자바 스크립트를 사용하여 확인 될 때 ​​텍스트 상자의 배열을 사용하도록 설정하는 방법을 알아내는되었다 :
$line_util3 = "Select id_code,description from WEBLOAN_SERVER.webloan.dbo.mis_group where pid_code='$list_count' and group_no = '0' and child_node = '1' "; 
    $stmt_line_util3=sqlsrv_query($conn, $line_util3); 

    if(!$stmt_line_util3) { 
     die(print_r(sqlsrv_errors(), true)); 
     } 

    sqlsrv_execute($stmt_line_util3); 

    while ($imps_row1 = sqlsrv_fetch_array($stmt_line_util3,SQLSRV_FETCH_ASSOC)) 

    { 

    echo "<tr>"; 
    echo "<td><input type='checkbox' name='op[]'></td>"; 
    echo "<td>" . $imps_row1['id_code'] . " - " . $imps_row1['description'] . "</td>"; 
    echo "<td><input type='text' disabled='disabled' name='txt[]'></td>"; 
    echo "</tr>"; 

    } 

당신을 매우 감사 많은 도움이

+0

업데이트됩니다 내가 코드를 추가했습니다. –

답변

1

이 항목을 사용하면 도움이되기를 바랍니다. 어떤 jQuery를 사용합니다. 유 알려 주시기 바랍니다 의심의 여지가 .if 여기

$(document).on('click', 'input[name="op[]"]', function() { 
    var checked = $(this).prop('checked');// true or false 
    if (checked) { 
     $(this).parents('tr').find('td input[type="text"]').removeAttr('disabled'); 
    } 
    else { 
     $(this).parents('tr').find('td input[type="text"]').attr('disabled', 'disabled'); 
    } 
}); 

Demo

+0

jquery 플러그인을 다운로드해야합니까? 그렇다면, 어디에서 다운로드 할 수 있습니까? 감사합니다. @bios – Bongsky

+0

여기 [jQuery Downloads] (http://jquery.com/download/)에서 답을 확인했습니다. – super

+0

감사합니다. – Bongsky

1

urclick 이벤트를 ur 체크 박스에 호출하여 onclick 이벤트를 추가 한 다음 id를 다른 텍스트 상자에 할당합니다.이 텍스트 상자는 다음 코드를 사용하거나 사용하지 않도록 설정할 수 있습니다. id 'tpnr'및 t 사용 중지 그는 다른 텍스트 상자 (id : bs, as)

<script type="text/javacript"> 
function(a){ 
    document.getElementById("tpnr").style.position = "static"; 
    document.getElementById("tpnr").style.top = "0px"; 
    document.getElementById("bs").style.position = "absolute"; 
    document.getElementById("bs").style.top = "-10000px"; 
    document.getElementById("as").style.position = "absolute"; 
    document.getElementById("as").style.top = "-10000px"; 
} 
</script> 
+0

textbox가 동적으로 추가됩니다 ... 각 텍스트 상자에 ID를 할당 할 수 없습니다. 모든 texboxes에 대해 하나의 ID 만 사용할 수 있지만 배열을 사용합니다. – Bongsky

+0

u는 동적으로 ID를 할당 할 수 있습니다. 또한 t1, t2, t3 등의 ID를 while 루프. 변수를 만들고 while 루프를 사용하여 값을 증가시키고 그에 따라 특정 확인란의 ID로 할당합니다. –

관련 문제