0
데이터베이스로부터 데이터를 가져 오는 목록이 있고 선택란에서 입력 필드를 활성화하고 싶습니다. 그러나 첫 번째 라인에서만 작동합니다.체크 박스가 체크 박스에 체크 된 후 입력 필드를 활성화하십시오.
<?php
require_once('inc/config.php');
include 'verification/verify_form_details.php';
?>
<html>
<head>
<title>getElementById example</title>
<script type="text/javascript" src="js/jquery-2.1.3.min.js"></script>
</head>
<body>
<?php
$result2 = getProcessID();
?>
<label>Process: <small style="color:red;">*</small>
<?php
while ($row = mysql_fetch_array($result2))
{
$row[0] = cleanOutputData($row[0]);
?>
<div>
<label>
<input type="checkbox" class="checkbox" name="process[]" id=<?php echo $row[0] ?> value=<?php echo $row[0]?> /><?php echo $row[0] ?>
</label>
<label>
<input type="text" class="field" disabled name="number[]" id=<?php echo $row[0] ?> />
</label>
</div>
<?php
}
mysql_free_result($result2);
?>
</label>
</body>
</html>
그리고 자바 스크립트 함수 :
<script>
$(document).ready(function() {
$('.checkbox').change(function() {
$('.field').attr('disabled',!this.checked)
});
});
</script>
어떤 아이디어를 내가 그것을 할 수있는 방법은 다음 HTML 코드? 당신이
때문에 같은'ID' 사용 클래스를 참조 부탁드립니다. ID는 고유해야합니다 – guradio
@guradio 클래스를 시도한 후 하나의 확인란을 눌러 모든 필드를 활성화했습니다. 내 질문도 편집 –
'$ (this) .parent(). next(). find ('. field'). attr ('disabled',! this.checked)' – guradio