Hi,

I want to disable other textboxes, which is related to single (i.e.connection type) texbox and the textbox are assigned in array[] row wise manner.

This is working for sinle row but when I add multiple it's not working.

Please help to resolve this issue.

<button type="button" class="btn btn-info" id="delete">- Delete</button>
                                    <button type="button" class="btn btn-info" id="addmore">+ Add More</button>
                                    <div class="clear"></div><br>
                                    <table>
                                      <tr align="center">
                                          <td><input class='check_all' type='checkbox' onclick="select_all()"/></td>
                                          <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><input type='text' name='flag_seq[]' id='flag_seq'/></td>
                                            <td><input type='text' name='conn_type[]' onkeyup="AddToStack();" onChange='showptype(this.value)' id='conn_type'></td>
                                            <td> <!-- <input type="text" name="ptype[]" id="ptype"  onChange="checkEnableSubmit();"> --> 
                                            <div id="txtHint"></div>
                                            </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>
                                    <div class="form-group"><input name="Submit" type="submit" id="Submit" class="btn btn-info" value="Submit"></div>



    <script type="text/javascript">

function showptype(str1)
{
if (str1=="")
  {
  document.getElementById("txtHint").innerHTML="";
  return;
  }
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","getptype.php?q="+str1,true);
xmlhttp.send();
}
</script>
<script language="javascript">
var i=2;
$("#addmore").on('click',function(){
    var data="<tr><td><input type='checkbox' class='case'/></td>";
    data +="<td><input type='text' name='flag_seq[]' id='flag_seq"+i+"'/></td><td><input type='text' name='conn_type[]' id='conn_type"+i+"'></td> <td><input type='text' name='ptype[]' id='ptype"+i+"'' onChange='checkEnableSubmit();'></td><td><input type='text' name='cond[]' id='cond"+i+"'></td><td><input type='text' name='oqs[]' id='oqs'></td><td><input type='text' name='rcode[]' id='rcode"+i+"'></td><td><input type='text' name='report_name[]' id='report_name"+i+"'></td><td><input type='text' name='report_ver[]' id='report_ver"+i+"'></td><td><input type='text' name='report_desc[]' id='report_desc"+i+"'></td><td><input type='text' name='dep_flag_seq[]' id='dep_flag_seq"+i+"'></td><td><input type='text' name='dep_rep_desc[]' id='dep_rep_desc"+i+"'></td><td><input type='text' name='pdf_csv[]' id='pdf_csv"+i+"'></td><td><input type='text' name='manual_break[]' id='manual_break"+i+"'></td><td><input type='text' name='Job_que[]' id='Job_que"+i+"'></td><td><input type='text' name='eserver_name[]' id='eserver_name"+i+"'></td><td><input type='text' name='email_grp[]' id='email_grp"+i+"'></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>

<!------------   VALIDATION FOR TYPE (JDE,SQL,FILE)     ---------------->


<script type="text/javascript">

function AddToStack() {
        var a = document.getElementById('conn_type');


            a.focus();

            //clear input an refocus:
            if(a.value == "JDE")
              {
                document.getElementById('cond').disabled=true;
                document.getElementById('rcode').disabled=true;
                document.getElementById('oqs').disabled=true;


                document.getElementById('report_name').disabled=false;      
                 document.getElementById('report_ver').disabled=false;      
                 document.getElementById('report_desc').disabled=false; 
                 document.getElementById('dep_flag_seq').disabled=false;      
                 document.getElementById('dep_rep_desc').disabled=false;      
                 document.getElementById('pdf_csv').disabled=false;      
                 document.getElementById('Job_que').disabled=false;   
                 document.getElementById('eserver_name').disabled=false;
              }
            else if(a.value == "SQL")
                {

                 document.getElementById('cond').disabled=true;      
                 document.getElementById('report_name').disabled=true;      
                 document.getElementById('report_ver').disabled=true;      
                 document.getElementById('report_desc').disabled=true; 
                 document.getElementById('dep_flag_seq').disabled=true;      
                 document.getElementById('dep_rep_desc').disabled=true;      
                 document.getElementById('pdf_csv').disabled=true;      
                 document.getElementById('Job_que').disabled=true;   
                 document.getElementById('eserver_name').disabled=true;


                 document.getElementById('rcode').disabled=false;
                document.getElementById('oqs').disabled=false;


                }
            else if(a.value == "FILE")
                {
                 document.getElementById('rcode').disabled=true;
                 document.getElementById('cond').disabled=true;      
                 document.getElementById('report_name').disabled=true;      
                 document.getElementById('report_ver').disabled=true;      
                 document.getElementById('report_desc').disabled=true; 
                 document.getElementById('dep_flag_seq').disabled=true;      
                 document.getElementById('dep_rep_desc').disabled=true;      
                 document.getElementById('pdf_csv').disabled=true;      
                 document.getElementById('Job_que').disabled=true;   
                 document.getElementById('eserver_name').disabled=true;

                 document.getElementById('oqs').disabled=false;

                }

        }
</script>



getptype.php
---------------------

<?php
session_start();
include('conn.php');

$q=$_GET["q"];

$qi = trim($_GET["q"]);
 //$qi = count($q);

$query="select * from $database.FQ64006 WHERE SCYQ64CTYPE='$qi'";
$btype=odbc_exec($connection,$query);
//$bcom = odbc_result($bcompany,"MCCO");
?>
<input type="text" name="ptype" id="ptype" value="<?php $SCYQ64TYPE1 = odbc_result($btype,"SCYQ64TYPE"); echo $SCYQ64TYPE = trim($SCYQ64TYPE1) ?>" readonly >

<script type="text/javascript">
function checkEnableSubmit() { 
var ptype = document.getElementById('ptype'); 
var cond = document.getElementById('cond');
var oqs = document.getElementById('oqs');
var rcode = document.getElementById('rcode');
var report_name = document.getElementById('report_name');
var report_ver = document.getElementById('report_ver');
cond.disabled = (ptype.value == "JDE"); 
oqs.disabled = (ptype.value == "JDE"); 
rcode.disabled = (ptype.value == "JDE");
report_name.disabled = (ptype.value == "FILE"); 
report_ver.disabled = (ptype.value == "FILE"); 
rcode.disabled = (ptype.value == "FILE");
cond.disabled = (ptype.value == "SQL"); 
report_ver.disabled = (ptype.value == "SQL"); 
rcode.disabled = (ptype.value =="SQL");
} 
</script>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.