Hi
I am working on dynamic add row. In that if a value is enter in ptype box it should disable the releated textbox filed based on the value. i written code but its not working can any please help me to solve this issue
html Page
<form id='students' method='post' name='students' action='index.php'>
<table border="1" cellspacing="0">
<tr>
<th><input class='check_all' type='checkbox' onclick="select_all()"/></th>
<th>S. No</th>
<td>Line Number</td>
<td>Connection Type</td>
<td>Type</td>
<td>Condition</td>
<td>Open Query Statement</td>
<td>Return Code</td>
<td>Report Name</td>
<td>Report Version 1</td>
<td>Report Description</td>
<td>Dep.Flag Sequence</td>
<td>Dep Report Description</td>
<td>Email PDF / CSV </td>
<td>Manual Break</td>
<td>Job Queue</td>
<td>Execution Server Name</td>
<td>Email Grp Name</td>
</tr>
<tr>
<td><input type='checkbox' class='case'/></td>
<td>1.</td>
<td><input type="text" name="flag_seq[]" id="flag_seq"></td>
<td><input type="text" name="conn_type[]" id="conn_type"></td>
<td><input type="text" name="ptype[]" id="ptype" onChange="checkEnableSubmit();"></td>
<td><input type="text" name="cond[]" id="cond"></td>
<td><input type="text" name="oqs[]" id="oqs"></td>
<td><input type="text" name="rcode[]" id="rcode"></td>
<td><input type="text" name="report_name[]" id="report_name"></td>
<td><input type="text" name="report_ver[]" id="report_ver"></td>
<td><input type="text" name="report_desc[]" id="report_desc"></td>
<td><input type="text" name="dep_flag_seq[]" id="dep_flag_seq"></td>
<td><input type="text" name="dep_rep_desc[]" id="dep_rep_desc"></td>
<td><input type="text" name="pdf_csv[]" id="pdf_csv"></td>
<td><input type="text" name="manual_break[]" id="manual_break"></td>
<td><input type="text" name="Job_que[]" id="Job_que"></td>
<td><input type="text" name="eserver_name[]" id="eserver_name"></td>
<td><input type="text" name="email_grp[]" id="email_grp"></td>
</tr>
</table>
<button type="button" class='delete'>- Delete</button>
<button type="button" class='addmore'>+ Add More</button>
<p>
<input type='submit' name='submit' value='submit' class='but'/></p>
</form>
Javasacript
<script src='js/jquery-1.9.1.min.js'></script>
<script>
var i=2;
$(".addmore").on('click',function(){
var data="<tr><td><input type='checkbox' class='case'/></td><td>"+i+".</td>";
data +="<td><input type='text' name='flag_seq[]' id='flag_seq'/></td><td><input type='text' name='conn_type[]' id='conn_type'></td> <td><input type='text' name='ptype[]' id='ptype' onChange='checkEnableSubmit();'></td><td><input type='text' name='cond[]' id='cond'></td><td><input type='text' name='oqs[]' id='oqs'></td><td><input type='text' name='rcode[]' id='rcode'></td><td><input type='text' name='report_name[]' id='report_name'></td><td><input type='text' name='report_ver[]' id='report_ver'></td><td><input type='text' name='report_desc[]' id='report_desc'></td><td><input type='text' name='dep_flag_seq[]' id='dep_flag_seq'></td><td><input type='text' name='dep_rep_desc[]' id='dep_rep_desc'></td><td><input type='text' name='pdf_csv[]' id='pdf_csv'></td><td><input type='text' name='manual_break[]' id='manual_break'></td><td><input type='text' name='Job_que[]' id='Job_que'></td><td><input type='text' name='eserver_name[]' id='eserver_name'></td><td><input type='text' name='email_grp[]' id='email_grp'></td></tr>";
$('table').append(data);
i++;
});
</script>
<script>
$(".delete").on('click', function() {
$('.case:checkbox:checked').parents("tr").remove();
});
</script>
<script>
function select_all() {
$('input[class=case]:checkbox').each(function(){
if($('input[class=check_all]:checkbox:checked').length == 0){
$(this).prop("checked", false);
} else {
$(this).prop("checked", true);
}
});
}
</script>
Code for disable Textbox
<script type="text/javascript">
function checkEnableSubmit() {
var ptype = document.getElementById('ptype');
var cond = document.getElementById('cond');
var report_name = document.getElementById('report_name');
var report_ver = document.getElementById('report_ver');
var rcode = document.getElementById('rcode');
var oqs = document.getElementById('oqs');
cond.disabled = (ptype.value == "JDE");
oqs.disabled = (ptype.value == "JDE");
rcode.disabled = (ptype.value == "JDE");
rcode.disabled = (ptype.value == "FILE");
report_name.disabled = (ptype.value == "FILE");
report_ver.disabled = (ptype.value == "FILE");
cond.disabled = (ptype.value =="SQL");
report_name.disabled = (ptype.value =="SQL");
report_ver.disabled = (ptype.value =="SQL");
}
</script>