Current File : //home/obabain/autoclutchess_obaba_in/Addcustomeritems.jsp
<%@include file="master.jsp" %>
 <%@ include file="Connection.jsp" %>
 <% String id=request.getParameter("Id"); 
 session.setAttribute("sd_id",id);
    //System.out.println(id);
 %>
 
  <%!
 String clname=null;  %>
 
<%Statement st=con.createStatement(); 
ResultSet rs= null;
  id=request.getParameter("Id");
 rs=st.executeQuery("select * from ip_clients where client_id="+id+"");
 while(rs.next())
 {
 clname=rs.getString("client_name");
 }
%>

<style type="text/css">
.highlight-error {
  border-color: red;
}
.template { display: none; }
</style>
<script src="http://code.jquery.com/jquery-2.1.1.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> 
 <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js"></script>
<%-- <body onload="custgroup(<%=gp%>,'<%=drcr%>')"> --%>
<div class="row">
<form action="CustomeritemDA.jsp" method="post">
<div class="row" style="width:108%;">
<div class="col-md-9"  style="background-color:white;">
<div class="panel panel-default" >
        <div class="panel-heading main-color-bg" style="height:40px;">
          <!--  <a href="Dashboard.jsp" style="color:white;"><b>Home&nbsp;&nbsp;/</b></a> 
       <a href="" style="color:white;"><b>Master&nbsp;&nbsp;/</b></a>  --> 
      
        <a href="#" style="color:white;"><b> Product Edit</b></a>
     
            <a class="btn btn-danger" style="margin-left:995px;margin-top:-25px;" href="ViewCustomer.jsp">View</a>
<div style="margin-top:-25px;margin-left:970px;">
 <!-- <a style="background:" class="btn btn-danger" href="material_type.jsp">New</a>  -->

</div></div></div>
        <!--  <div align="right" >
<a  style="background:#204b58;" class="btn btn-info"  href="ViewCustomer.jsp">View</a>
 </div> -->
    
                              <center>  <h3> Client Name:<%=clname%></h3></center> 
                              
                              <input type="hidden" name="client" value="<%=clname%>">
                               <input type="hidden" name="clientid" value="<%=id%>">
                               
                               
<div style="overflow-x:auto;width:100%;">
<table id="someTable"  class="table table-bordered table-hover additionalMargin alignment">                              
           <thead>
            <tr class="success">
            
            <th>Delete</th> 
                <th class="code">SL.No</th>
                <!-- <th class="Cname">Country</th> -->                     
                <th class="Product Name">Part Name</th>  
                 <th class="Product Name">Part No</th>
                  <th class="Product Name">Price</th>  
                  <!--  <th>Edit</th> -->  
                                                                               
            </tr>
       </thead>
              <tbody>
            <%
              	 try{
		int zi=1;
    String query="";		
    query="select tb.*,(select a1 from components where id=tb.product)product1 from ip_clients_product tb where client_id='"+id+"'";
 	ResultSet rs1=st.executeQuery(query);
 	while(rs1.next())
 	{
 		%> 
            <tr>
                 
               
             <!-- <td>
                    <a href="CustomerEdititem.jsp?Id=<%=rs1.getString("c_id") %>&proid=<%=rs1.getString("product")%>&clientid=<%=id%>"><span class="glyphicon glyphicon-pencil"></span></a>
                </td>-->
              
              <td>
                    <a href="CustomerDeleteitem.jsp?Id=<%=rs1.getString("c_id")%>" onclick = "if (! confirm('Are you Sure To Delete?')) { return false; }"><span class="glyphicon glyphicon-remove"></span></a>
                </td> 
                 <th><%=zi%></th> 
                
               <td> <%=rs1.getString("product1")%> </td>
               <td> <%=rs1.getString("partno")%> </td>
               <td> <%=rs1.getString("price")%> </td>
                                                          
          <%  
          zi++;	}
 	
 	}
              catch(Exception el){
            	  System.out.println(el);
              }
 	%> 
            </tr>
          
            </tbody>
            </thead>
                        
            
            </table>
      </div>
            
            
            
     <div class="panel-body"  >
     <!-- <div align="right" >
<a  style="background:#204b58;" class="btn btn-info"  href="ViewCustomer.jsp">View</a>
 </div> -->
    
      
          <hr>
            
            <h3>Add Products:</h3>         
            <br>                                
        <br>
         <table class="table table-bordered table-hover additionalMargin alignment" id="table1" style="width:65%;margin-left:200px">
          <thead><tr class="info">
 <!--   <th style="text-align:center;width:150px; ">Sl No:</th>  -->
     <th style="text-align:center;width:200px"> Part&nbsp;Name:</th>
     <th style="text-align:center;width:200px"> Part&nbsp;No:</th>
    <th style="text-align:center;width:200px"> Product&nbsp;Price:</th>
    
    <th style="text-align:center;width:80px; ">Delete</th>  </tr></thead>
   
    <tr class='template'>
   <!--  <td>
    <input type="text" name="part[]" class="amt form-control" value="0">
    </td> -->
     <td>
    <select class="form-control selectMat" name="product[]" id="ddlsname" style="width:100%;">
                <option value="0"></option>
           <%
           ResultSet rs12=st.executeQuery("select * from components");
          while(rs12.next())
          {
        	%> 
        <option value="<%=rs12.getString("id")%>"><%=rs12.getString("a1") %>&nbsp;--&nbsp;<%=rs12.getString("a2") %></option>
          <%} %>       
          
          
                </select>
    </td>
    
    <td>  <span class="project" style=""> 
                <input type="text" class="descr form-control input-group-lg reg_name " name="partno[]" >  
       
           </span>      </td> 
           

<td>  <span class="project" style=""> 
                <input type="text" class=" form-control  " name="price[]" >  
       
           </span>      </td> 
   
    
   
             
               <td><a href='#'  onclick='deleteRow(this)'><i class='glyphicon glyphicon-trash'></a></td> 
              
     </tr>
     </table>
      <a id='add' style="margin-left:200px" class="pull-left btn btn-default">ADD</a><br>
       
         <br>       
      <div class="modal-footer" id="contact_submit">
       <input type="button" value="Back" style="background:#204b58;margin-right:720px" class="btn btn-info pull-left" onclick="goBack()"/>
        <a class="btn btn-default" href="#">Reset</a>
        <button type="submit" style="background:#204b58" class="btn btn-info" >Save Changes</button>
      </div>
 

    </div>
  </div>
</div>
</div>
</section>
<%-- <% }else{ 
     response.sendRedirect("login.jsp");
    } %> --%>
 <script src="http://cdn.ckeditor.com/4.6.1/standard/ckeditor.js"></script>
     <script src="http://cdn.ckeditor.com/4.6.1/standard/ckeditor.js"></script>  
   
 <script src="https://code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="https://cdn.jsdelivr.net/jquery.validation/1.16.0/jquery.validate.min.js"></script>
<script src="https://cdn.jsdelivr.net/jquery.validation/1.16.0/additional-methods.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script type="text/javascript">
 $('[data-type="adhaar-number"]').keyup(function() {
  var value = $(this).val();
  value = value.replace(/\D/g, "").split(/(?:([\d]{4}))/g).filter(s=>s.length > 0).join("-");
  $(this).val(value);
});

$('[data-type="adhaar-number"]').on("change, blur", function() {
  var value = $(this).val();
  var maxLength = $(this).attr("maxLength");
  if (value.length != maxLength) {
    $(this).addClass("highlight-error");
    alert("Aadhar card number not valid");
  } else {
    $(this).removeClass("highlight-error");
  }
});</script>
</form>
</div>
<script type="text/javascript">
function goBack() {
    window.history.back();
   
};
</script>



<%@include file="footer.jsp" %>
</body>
<script>
    $(document).on("change",".selectMat",function(){
      
      var p=[];
      var str=$(".selectMat:last").find("option:selected").text();
      //alert(str);
      p=str.split('--');
      var a=p[1];
      $(".descr:last").val(a);
      $(".revno:last").val(p[2]);
      $(".drgno:last").val(p[3]);
      $(".div:last").val(p[4]);
      $(".buyer:last").val(p[5]);
      $(".price:last").val(p[6]);
    });
    </script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
  <script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js"></script>  
  <script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.1/js/select2.min.js"></script> 
   <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>  
<script>
$(function() {
    initThings();

    $('#add').on('click', function() { add_row($('#table1')); });
});


function add_row($table) {
    var tr_id = $table.find('tr').length - 1;
    var $template = $table.find('tr.template');
    var $tr = $template.clone().removeClass('template').prop('id', tr_id);

    $tr.find(':input').each(function() {
        if($(this).hasClass('hasDatepicker')) {
            $(this).removeClass('hasDatepicker').removeData('datepicker');
        }

        var input_id = $(this).prop('id');
        input_id = input_id + tr_id;
        $(this).prop('id', input_id);

        var new_name = $(this).prop('name');
        new_name = new_name.replace('[0]', '['+ tr_id +']');
        $(this).prop('name', new_name);

        $(this).prop('value', '');
    });
    $table.find('tbody').append($tr);
    $('.byto:last').val(1);

    $(".dateControl", $tr).datepicker({
        dateFormat: "dd-mm-yy"
    });

    $(".selectType", $tr).select2();
    $(".qty", $tr).select2();
    $(".selectType:last").val(0).trigger("change");
    $(".qty:last").val(0).trigger("change");
}

function initThings() {
    add_row($('#table1'));
} 
	        </script>
	       
   
	        
<script  langauge="JavaScript">
    function deleteRow(btn) {
	  var row = btn.parentNode.parentNode;
	  row.parentNode.removeChild(row);
	  var sum = 0;
	  var sum2=0;
	    $(".amt").each(function(){
	        sum += +$(this).val();
	    });
	    $(".total").val(sum);
	    
	    $(".amt2").each(function(){
	        sum2 += +$(this).val();
	    })
	    $(".total2").val(sum2);
	    
	};
</script> 






</html>