<div class="cbi-section-create cbi-tblsection-create">
  <br />
  <table class="cbi-section-table" style="width:1000px; margin-center:5px">
    <tr class="cbi-section-table-descr">
      <th class="cbi-section-table-cell"><%:Types%></th>
      <th class="cbi-section-table-cell"><%:Slave ID%></th>
      <th class="cbi-section-table-cell"><%:Data Type%></th>
      <th class="cbi-section-table-cell"><%:Starting Address%></th>
      <th class="cbi-section-table-cell"><%:Quantity %></th>
      <th class="cbi-section-table-cell"><%:IP Address%></th>
      <th class="cbi-section-table-cell"><%:Port%></th>
      <th class="cbi-section-table-cell"></th>
    </tr>
    <tr class="cbi-section-table-row">
      <td class="cbi-section-table-cell" style="width:115px">
        <select onChange="xyz();" class="cbi-input-select" id="_new.types" name="_new.types">
          <option value="01 Read Coils">01 Read Coils</option>
          <option value="02 Read Discrete Inputs">02 Read Discrete Inputs</option>
          <option value="03 Read Holding Registers">03 Read Holding Registers</option>
          <option value="04 Read Input Registers">04 Read Input Registers</option>
          <!-- <option value="05 Write Single Coil">05 Write Single Coil</option>
            <option value="06 Write Single Register">06 Write Single Register</option> -->
        </select>
      </td>
      <td class="cbi-section-table-cell" style="width:7px">
        <input type="text" class="cbi-input-text" id="_new.slaveid"  name="_new.slaveid" />
      </td>
      <td class="cbi-section-table-cell" style="width:100px">
        <select disabled=true class="cbi-input-select" id="_new.dtype" name="_new.dtype">
          <option value="01">01 For Types 01 & 02</option>
          <option value="02">02 Signed Int</option>
          <option value="03">03 Unsigned Int</option>                                        
          <option value="04">04 Floating Point</option>
          <option value="05">05 Signed Long</option> 
          <option value="06">06 Unsigned Long (Dword)</option> 
          <option value="07">07 Double</option> 
          <option value="08">08 Unsigned Long Reverse (Dword Reverse)</option>
          <option value="09">09 Signed Long Reverse</option> 
          <option value="10">10 Floating Ponting Reverse</option> 
          <option value="11">11 BCD 2 Byte</option> 
          <option value="12">12 BCD 4 Byte</option>                               
          <option value="13">13 BCD 4 Byte Reverse</option>
          <option value="14">14 Double Reverse</option>
        </select>      
      </td>
      <td class="cbi-section-table-cell" style="width:7px">
        <input type="text" class="cbi-input-text" id="_new.address" name="_new.address" />
      </td>
      <td class="cbi-section-table-cell" style="width:10px">
        <input type="text" class="cbi-input-text" id="_new.length" name="_new.length" />
      </td>
      <td class="cbi-section-table-cell" style="width:40px">           
        <input type="text" class="cbi-input-text" id="_new.ip_addr" name="_new.ip_addr" placeholder="<%:0.0.0.0%>"/>  
      </td>
      <td class="cbi-section-table-cell" style="width:20px">           
        <input type="text" class="cbi-input-text" id="_new.port" name="_new.port" placeholder="<%:0-65535%>"/>  
      </td> 
      <td class="cbi-section-table-cell">
        <input type="submit" class="cbi-button cbi-button-add" onClick="return empty();"   
        name="cbi.cts.<%=self.config%>.<%=self.sectiontype%>.<%=section%>" value="<%:Add%>" />
      </td>                                                                                                                  
    </tr>                                                                                                                 
  </table>      

          <script type="text/javascript">//<![CDATA[                                                     
          cbi_validate_field('_new.slaveid', true, 'integer');  
          cbi_validate_field('_new.address', true, 'integer');
          cbi_validate_field('_new.length', true, 'integer');
          cbi_validate_field('_new.ip_addr', true, 'ip4addr');
          cbi_validate_field('_new.port', true, 'portrange');    
          var a = document.getElementsByName("var");
          a.value = true; 
          function empty()
          {
            var x = document.getElementById('_new.slaveid');
            var r = document.getElementById('_new.dtype');
            var n = document.getElementById('_new.address');
            var m = document.getElementById('_new.length');
            var ip = document.getElementById('_new.ip_addr');                                                    
            var port = document.getElementById('_new.port');
            n.disabled = false;
            m.disabled = false;
            r.disabled = false;
            ip.disabled = false;
            port.disabled = false;

            if (x.value != "" && n.value != "" && m.value != "" && ip.value != "" && port.value != "" )
            {
              return true;
            }
            else 
            {

              alert (" Some field are empty");
              return false;
            }
          }        
          function xyz()                                                                                            
          {                                                                                                         
            var op = document.getElementById('_new.types');
            var r = document.getElementById('_new.dtype');
            if (op.value == "02 Read Discrete Inputs" || op.value == "01 Read Coils")
            { 
              r.disabled = true;
              r.selectedIndex=0;
            }
            else
            {
              r.disabled = false;
              r.selectedIndex=2;
            }
          } 
          cbi_validate_field('cbi.cts.<%=self.config%>.<%=self.sectiontype%>.<%=section%>', true, 'uciname');
          //]]></script>                                                                                                                                

        </div>                         


