javascript — Как я могу решить эту проблему, в полях Количество и Общая цена отображается пустой результат, когда я выбираю любой продукт из выпадающего списка

Как я могу решить эту проблему, в полях Количество и Общая цена отображается пустой результат, когда я выбираю любой продукт из выпадающего

Я сталкиваюсь с проблемой, что у меня есть несколько выпадающих списков, в которых при выборе цены и количества продукта и общей цены будут видны, и если выбрать вариант Выбрать продукт, все поля, соответствующие этому продукту, будут пустыми, как я могу решить это в основном я пробовал это, но я сталкиваюсь с проблемой, что, когда я выбираю другое количество продукта и общую цену, поле показывает мне пустой результат. Если я выберу материнскую плату из списка, цена и количество точно отобразятся, когда я выберу Выбрать материнскую плату, все поля, соответствующие материнской плате, будут пустыми, проблема заключается в том, что при выборе веб-камеры поле количества и общей цены пустое в начале. как я могу разобраться?

Материнская плата выбрана, когда-нибудь все работает нормально

Когда я нажимаю «Выбрать материнскую плату», все поля становятся пустыми.

Когда я выбираю количество веб-камеры и общая цена не отображается, проблема заключается в следующем

 {amp}lt;?php include("includes/headerLinks.php"); include("includes/nav.php"); // include("includes/db.php"); // include("includes/header.php"); $connect = mysqli_connect("localhost", "root", "", "onlinequotation"); function motherboard_brand($connect) { $output = ''; $sql = "SELECT * FROM products WHERE category='Motherboard' AND status='Active'"; $result = mysqli_query($connect, $sql); while($row = mysqli_fetch_array($result)) { $output .= '{amp}lt;option value="'.$row["id"].'"{amp}gt;'.$row["product_title"].'{amp}lt;/option{amp}gt;'; } return $output; } function processor_brand($connect) { $output = ''; $sql = "SELECT * FROM products WHERE category='Processor' AND status='Active'"; $result = mysqli_query($connect, $sql); while($row = mysqli_fetch_array($result)) { $output .= '{amp}lt;option value="'.$row["id"].'"{amp}gt;'.$row["product_title"].'{amp}lt;/option{amp}gt;'; } return $output; } // for ram function ram_brand($connect) { $output = ''; $sql = "SELECT * FROM products WHERE category='Ram' AND status='Active'"; $result = mysqli_query($connect, $sql); while($row = mysqli_fetch_array($result)) { $output .= '{amp}lt;option value="'.$row["id"].'"{amp}gt;'.$row["product_title"].'{amp}lt;/option{amp}gt;'; } return $output; } // For Hardisk function harddisk_brand($connect) { $output = ''; $sql = "SELECT * FROM products WHERE category='Hard-disk' AND status='Active'"; $result = mysqli_query($connect, $sql); while($row = mysqli_fetch_array($result)) { $output .= '{amp}lt;option value="'.$row["id"].'"{amp}gt;'.$row["product_title"].'{amp}lt;/option{amp}gt;'; } return $output; } ?{amp}gt; {amp}lt;hr class="offset-top"{amp}gt; {amp}lt;div class="white"{amp}gt; {amp}lt;div class="container checkout"{amp}gt; {amp}lt;h1{amp}gt;Quotation Generator{amp}lt;/h1{amp}gt; {amp}lt;hr class="offset-sm"{amp}gt; {amp}lt;/div{amp}gt; {amp}lt;/div{amp}gt; {amp}lt;hr class="offset-md"{amp}gt; {amp}lt;div class="container checkout"{amp}gt; {amp}lt;form method="POST" name="myForm"{amp}gt; {amp}lt;div class="row"{amp}gt; {amp}lt;div class="col-md-12 white" style="border-radius:30px"{amp}gt; {amp}lt;div class="checkout-cart"{amp}gt; {amp}lt;div class="content"{amp}gt; {amp}lt;!-- contact form --{amp}gt; {amp}lt;div class="row"{amp}gt; {amp}lt;div class="col-md-4 col-md-offset-4"{amp}gt; {amp}lt;div class="form-group"{amp}gt; {amp}lt;label for="form_name"{amp}gt;Firstname *{amp}lt;/label{amp}gt; {amp}lt;input id="name" type="text" name="name" class="form-control" placeholder="Please enter your Name *"{amp}gt; {amp}lt;/div{amp}gt; {amp}lt;/div{amp}gt; {amp}lt;/div{amp}gt; {amp}lt;div class="row"{amp}gt; {amp}lt;div class="col-md-4 col-md-offset-4"{amp}gt; {amp}lt;div class="form-group"{amp}gt; {amp}lt;label for="form_lastname"{amp}gt;Mobile *{amp}lt;/label{amp}gt; {amp}lt;input id="mobile" type="text" name="mobile" class="form-control" placeholder="Please enter your Mobile# *"{amp}gt; {amp}lt;/div{amp}gt; {amp}lt;/div{amp}gt; {amp}lt;/div{amp}gt; {amp}lt;div class="row"{amp}gt; {amp}lt;div class="col-md-4 col-md-offset-4"{amp}gt; {amp}lt;div class="form-group"{amp}gt; {amp}lt;label for="form_lastname"{amp}gt;Email *{amp}lt;/label{amp}gt; {amp}lt;input id="email" type="email" name="email" class="form-control" placeholder="Please enter Email *"{amp}gt; {amp}lt;/div{amp}gt; {amp}lt;!-- {amp}lt;div id="error" style="text-align:center;display:none"{amp}gt;Fill all the textboxes{amp}lt;/div{amp}gt; --{amp}gt; {amp}lt;/div{amp}gt; {amp}lt;/div{amp}gt; {amp}lt;!-- End contact form --{amp}gt; {amp}lt;table class="table table-bordered table-striped"{amp}gt; {amp}lt;tr style="background-color:#00a1b4"{amp}gt; {amp}lt;th{amp}gt; Name {amp}lt;/th{amp}gt; {amp}lt;th{amp}gt; Products {amp}lt;/th{amp}gt; {amp}lt;th {amp}gt; QUANTITY {amp}lt;/th{amp}gt; {amp}lt;th{amp}gt; Per Item Price {amp}lt;/th{amp}gt; {amp}lt;th{amp}gt; Total Price {amp}lt;/th{amp}gt; {amp}lt;/tr{amp}gt; {amp}lt;tr class="category motherboard" data-value="motherboard"{amp}gt; {amp}lt;td{amp}gt; {amp}lt;span{amp}gt;Motherboard{amp}lt;/span{amp}gt; {amp}lt;/td{amp}gt; {amp}lt;td{amp}gt; {amp}lt;select name="motherboard" id="motherboard" style="min-width: 100%;" class="select" onchange="getPrice(event)"{amp}gt; {amp}lt;option value="0"{amp}gt;Select Motherboard{amp}lt;/option{amp}gt; {amp}lt;?php echo motherboard_brand($connect); ?{amp}gt; {amp}lt;/select{amp}gt; {amp}lt;/td{amp}gt; {amp}lt;!-- QUANTITY --{amp}gt; {amp}lt;td{amp}gt; {amp}lt;input type="number" min="0" name="email" class="quantity" oninput="setTotalPrice(event)"/{amp}gt; {amp}lt;/td{amp}gt; {amp}lt;!-- per item price --{amp}gt; {amp}lt;td{amp}gt; {amp}lt;input type="text" readonly class="unit-price" {amp}gt; {amp}lt;/td{amp}gt; {amp}lt;!-- Total Price --{amp}gt; {amp}lt;td{amp}gt; {amp}lt;input type="text" readonly class="total-price"{amp}gt; {amp}lt;/td{amp}gt; {amp}lt;/tr{amp}gt; {amp}lt;tr class="category processor" data-value="processor"{amp}gt; {amp}lt;td{amp}gt; {amp}lt;span{amp}gt;Processor{amp}lt;/span{amp}gt; {amp}lt;/td{amp}gt; {amp}lt;td{amp}gt; {amp}lt;select name="processor" id="processor" style="min-width: 100%;" class="select processors" onchange="getPrice(event)"{amp}gt; {amp}lt;option{amp}gt;Select Processor{amp}lt;/option{amp}gt; {amp}lt;!-- {amp}lt;?php echo processor_brand($connect); ?{amp}gt; --{amp}gt; {amp}lt;/select{amp}gt; {amp}lt;/td{amp}gt; {amp}lt;!-- QUANTITY --{amp}gt; {amp}lt;td{amp}gt; {amp}lt;input type="number" min="0" name="email" class="quantity" oninput="setTotalPrice(event)"/{amp}gt; {amp}lt;/td{amp}gt; {amp}lt;!-- per item price --{amp}gt; {amp}lt;td{amp}gt; {amp}lt;input type="text" readonly class="unit-price" {amp}gt; {amp}lt;/td{amp}gt; {amp}lt;!-- Total Price --{amp}gt; {amp}lt;td{amp}gt; {amp}lt;input type="text" readonly class="total-price"{amp}gt; {amp}lt;/td{amp}gt; {amp}lt;/tr{amp}gt; {amp}lt;!-- End Processor Section --{amp}gt; {amp}lt;!-- Start Ram Section --{amp}gt; {amp}lt;tr class="category ram" data-value="ram"{amp}gt; {amp}lt;td{amp}gt; {amp}lt;span{amp}gt;Ram{amp}lt;/span{amp}gt; {amp}lt;/td{amp}gt; {amp}lt;td{amp}gt; {amp}lt;select name="ram" id="rams" style="min-width: 100%;" class="select" onchange="getPriceRam(event)"{amp}gt; {amp}lt;option id="ram1st"{amp}gt;Select Ram{amp}lt;/option{amp}gt; {amp}lt;!-- {amp}lt;?php echo ram_brand($connect); ?{amp}gt; --{amp}gt; {amp}lt;/select{amp}gt; {amp}lt;/td{amp}gt; {amp}lt;!-- QUANTITY --{amp}gt; {amp}lt;td{amp}gt; {amp}lt;input type="number" maxlength="6" min="0" min="10" name="email" class="quantity" oninput="setTotalPrice(event)"/{amp}gt; {amp}lt;/td{amp}gt; {amp}lt;!-- per item price --{amp}gt; {amp}lt;br{amp}gt; {amp}lt;td{amp}gt; {amp}lt;input type="text" readonly class="unit-price" {amp}gt; {amp}lt;/td{amp}gt; {amp}lt;!-- Total Price --{amp}gt; {amp}lt;td{amp}gt; {amp}lt;input type="text" readonly class="total-price"{amp}gt; {amp}lt;/td{amp}gt; {amp}lt;/tr{amp}gt; {amp}lt;!-- End Ram Section --{amp}gt; {amp}lt;!-- Start harddisk Section --{amp}gt; {amp}lt;tr class="category harddisk" data-value="harddisk"{amp}gt; {amp}lt;td{amp}gt; {amp}lt;span{amp}gt;Harddisk{amp}lt;/span{amp}gt; {amp}lt;/td{amp}gt; {amp}lt;td{amp}gt; {amp}lt;select name="harddisk" id="" style="min-width: 100%;" class="select" onchange="getPrice(event)"{amp}gt; {amp}lt;option{amp}gt;Select Harddisk{amp}lt;/option{amp}gt; {amp}lt;?php echo harddisk_brand($connect); ?{amp}gt; {amp}lt;/select{amp}gt; {amp}lt;/td{amp}gt; {amp}lt;!-- QUANTITY --{amp}gt; {amp}lt;td{amp}gt; {amp}lt;input type="number" maxlength="6" min="0" min="10" name="email" class="quantity" oninput="setTotalPrice(event)"/{amp}gt; {amp}lt;/td{amp}gt; {amp}lt;!-- per item price --{amp}gt; {amp}lt;br{amp}gt; {amp}lt;td{amp}gt; {amp}lt;input type="text" readonly class="unit-price" {amp}gt; {amp}lt;/td{amp}gt; {amp}lt;!-- Total Price --{amp}gt; {amp}lt;td{amp}gt; {amp}lt;input type="text" readonly class="total-price"{amp}gt; {amp}lt;/td{amp}gt; {amp}lt;/tr{amp}gt; {amp}lt;!-- End Harddisk Section --{amp}gt; {amp}lt;tr{amp}gt; {amp}lt;td colspan="4" align="right"{amp}gt;{amp}lt;b{amp}gt;Total Price : {amp}lt;/b{amp}gt;{amp}lt;/td{amp}gt; {amp}lt;td id="TotalPrice"{amp}gt;{amp}lt;/td{amp}gt; {amp}lt;/tr{amp}gt; {amp}lt;/table{amp}gt; {amp}lt;/div{amp}gt; {amp}lt;/div{amp}gt; {amp}lt;hr class="offset-lg hidden-xs"{amp}gt; {amp}lt;div class="col-sm-12"{amp}gt; {amp}lt;hr class="offset-md"{amp}gt; {amp}lt;div class="row"{amp}gt; {amp}lt;div class="col-xs-6 col-md-4 col-md-offset-3"{amp}gt; {amp}lt;!-- onclick="submitQuote(event);" --{amp}gt; {amp}lt;button class="btn btn-primary pull-right" type="button" onclick="submitQuote(event);" {amp}gt;Submit{amp}lt;/button{amp}gt; {amp}lt;/div{amp}gt; {amp}lt;/div{amp}gt; {amp}lt;hr class="offset-md"{amp}gt; {amp}lt;/div{amp}gt; {amp}lt;/div{amp}gt; {amp}lt;/form{amp}gt; {amp}lt;/div{amp}gt; {amp}lt;hr class="offset-lg"{amp}gt; {amp}lt;hr class="offset-sm"{amp}gt; {amp}lt;?php // include("includes/footer.php"); include("includes/jsLinks.php"); ?{amp}gt; {amp}lt;!-- For Processor --{amp}gt; {amp}lt;script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"{amp}gt;{amp}lt;/script{amp}gt; {amp}lt;script type="text/javascript"{amp}gt; function getPrice(e){ e.preventDefault(); // grandtotal(); var id = $(e.target).val(); // console.log(id); // ;unitPrice.value let parent = e.target.parentNode.parentNode; console.log(parent); let parentt = e.target.parentNode; // $("#selector option:selected"); console.log(parentt); let category = parent.getAttribute("data-value"); // console.log(category); $.ajax({ url:"load_data.php", method:"POST", data:{id:id}, success:function(data){ // console.log(data); let unitPrice = parent.querySelector("input.unit-price"); // console.log(unitPrice); unitPrice.value = data; $(parent).attr("data-id", id); $(parent).attr("data-quantity", 1); if($('.select').find(":selected").val() == 0) { parent.querySelector("input.quantity").value = ""; parent.querySelector("input.total-price").value = null; } else{ parent.querySelector("input.quantity").value = 1; parent.querySelector("input.total-price").value =  data * 1; } grandtotal(); } }); } function setTotalPrice(e){ e.preventDefault(); // console.log(event.target); let parent = e.target.parentNode.parentNode; // console.log(parent); let unitPrice = parent.querySelector("input.unit-price").value; let quantity = parent.querySelector("input.quantity").value; $(parent).attr("data-quantity", quantity); parent.querySelector("input.total-price").value = ( unitPrice) * ( quantity); grandtotal(); } // Grand Total function grandtotal() { var sum=0; $('.total-price').each(function(){ var item_val=parseFloat($(this).val()); if(isNaN(item_val)){ item_val=0; } sum =item_val; $('#TotalPrice').html(sum.toFixed(2)); }); } $("#motherboard").change(function(){ var mid = $("#motherboard").val(); // console.log(mid); $.ajax({ url: 'processor_data.php', method: 'post', data: 'mid='   mid }).done(function(processors) { // console.log(processors); $('#processor').empty().append('{amp}lt;option{amp}gt;Select Processor{amp}lt;/option{amp}gt;'); processors = JSON.parse(processors); var htmll = ''; processors.forEach(function(processor) { htmll  = '{amp}lt;option value="'   processor.id   '"{amp}gt;'   processor.product_title   '{amp}lt;/option{amp}gt;'; }) $('#processor').append(htmll); }); }) function getPriceRam(e){ e.preventDefault(); grandtotal(); var id = $(e.target).val(); // console.log(id); let parent = e.target.parentNode.parentNode; // console.log(parent); let category = parent.getAttribute("data-value"); // console.log(category); $.ajax({ url:"load_dataram.php", method:"POST", data:{id:id}, success:function(data){ // console.log(data); let unitPrice = parent.querySelector("input.unit-price"); // console.log(unitPrice); unitPrice.value = data; $(parent).attr("data-id", id); $(parent).attr("data-quantity", 1); parent.querySelector("input.quantity").value = 1; parent.querySelector("input.total-price").value =  data * 1; grandtotal(); } }); } $("#rams").change(function(){ var ramid = $("#rams").val(); // console.log(ramid); }) $("#processor").change(function(){ var pid = $("#processor").val(); $.ajax({ url: 'data.php', method: 'post', data: 'pid='   pid }).done(function(data) { // console.log(data); $('#rams').empty().append('{amp}lt;option{amp}gt;Select Ram{amp}lt;/option{amp}gt;'); data = JSON.parse(data); var html = ''; data.forEach(function(value) { html  = '{amp}lt;option value="'   value.id   '"{amp}gt;'   value.product_title   '{amp}lt;/option{amp}gt;'; }) $('#rams').append(html); }); }) function getPriceRam(e){ e.preventDefault(); grandtotal(); var id = $(e.target).val(); // console.log(id); let parent = e.target.parentNode.parentNode; // console.log(parent); let category = parent.getAttribute("data-value"); // console.log(category); $.ajax({ url:"load_dataram.php", method:"POST", data:{id:id}, success:function(data){ // console.log(id); let unitPrice = parent.querySelector("input.unit-price"); // console.log(unitPrice); unitPrice.value = data; $(parent).attr("data-id", id); $(parent).attr("data-quantity", 1); parent.querySelector("input.quantity").value = 1; parent.querySelector("input.total-price").value =  data * 1; grandtotal(); } }); } $("#rams").change(function(){ var ramid = $("#rams").val(); // console.log(ramid); }) // insert into db function submitQuote(e){ let username = document.getElementById("name").value; let mobile = document.getElementById("mobile").value; let email = document.getElementById("email").value; // if (name.length {amp}lt; 1 || mobile.length {amp}lt; 1 || email.length {amp}lt; 1 ) { // alert('Contact field cannot be empty.'); // // return false; // } // if ((name==null || name=="") {amp}amp;{amp}amp; (mobile==null || mobile=="") {amp}amp;{amp}amp; (email==null || email=="")) // { // alert("Please Fillout all the fields!"); // return false; // } if (username == "") { $("#name").css("border", "2px solid red"); $("#name").focus(); } if (mobile == "") { $("#mobile").css("border", "2px solid red"); $("#mobile").focus(); } if (email == "") { $("#email").css("border", "2px solid red"); $("#email").focus(); } else{ let categories = document.querySelectorAll("tr.category"); let name = document.getElementById("name").value; let mobile = document.getElementById("mobile").value; let email = document.getElementById("email").value; // console.log(name); // console.log(mobile); // console.log(email); let items = []; // console.log(categories); Array.from(categories).forEach(category={amp}gt;{ let item = {}; item.id =   category.getAttribute("data-id"); item.quantity =   category.getAttribute("data-quantity"); if(item.id !== 0){ items.push(item); } }); // console.log(items); let data = JSON.stringify(items); console.log(data); $.ajax({ type: "POST", contentType: "application/json; charset=utf-8", dataType: "json", data: { data: data }, complete: function () { if(data=='[]') { alert("Please Select product"); } else { window.location.href = "reciept.php?dist="   data   "{amp}amp;name="   name   "{amp}amp;mobile="   mobile   "{amp}amp;email="   email; } } }); } } {amp}lt;/script{amp}gt; в {amp}lt;?php include("includes/headerLinks.php"); include("includes/nav.php"); // include("includes/db.php"); // include("includes/header.php"); $connect = mysqli_connect("localhost", "root", "", "onlinequotation"); function motherboard_brand($connect) { $output = ''; $sql = "SELECT * FROM products WHERE category='Motherboard' AND status='Active'"; $result = mysqli_query($connect, $sql); while($row = mysqli_fetch_array($result)) { $output .= '{amp}lt;option value="'.$row["id"].'"{amp}gt;'.$row["product_title"].'{amp}lt;/option{amp}gt;'; } return $output; } function processor_brand($connect) { $output = ''; $sql = "SELECT * FROM products WHERE category='Processor' AND status='Active'"; $result = mysqli_query($connect, $sql); while($row = mysqli_fetch_array($result)) { $output .= '{amp}lt;option value="'.$row["id"].'"{amp}gt;'.$row["product_title"].'{amp}lt;/option{amp}gt;'; } return $output; } // for ram function ram_brand($connect) { $output = ''; $sql = "SELECT * FROM products WHERE category='Ram' AND status='Active'"; $result = mysqli_query($connect, $sql); while($row = mysqli_fetch_array($result)) { $output .= '{amp}lt;option value="'.$row["id"].'"{amp}gt;'.$row["product_title"].'{amp}lt;/option{amp}gt;'; } return $output; } // For Hardisk function harddisk_brand($connect) { $output = ''; $sql = "SELECT * FROM products WHERE category='Hard-disk' AND status='Active'"; $result = mysqli_query($connect, $sql); while($row = mysqli_fetch_array($result)) { $output .= '{amp}lt;option value="'.$row["id"].'"{amp}gt;'.$row["product_title"].'{amp}lt;/option{amp}gt;'; } return $output; } ?{amp}gt; {amp}lt;hr class="offset-top"{amp}gt; {amp}lt;div class="white"{amp}gt; {amp}lt;div class="container checkout"{amp}gt; {amp}lt;h1{amp}gt;Quotation Generator{amp}lt;/h1{amp}gt; {amp}lt;hr class="offset-sm"{amp}gt; {amp}lt;/div{amp}gt; {amp}lt;/div{amp}gt; {amp}lt;hr class="offset-md"{amp}gt; {amp}lt;div class="container checkout"{amp}gt; {amp}lt;form method="POST" name="myForm"{amp}gt; {amp}lt;div class="row"{amp}gt; {amp}lt;div class="col-md-12 white" style="border-radius:30px"{amp}gt; {amp}lt;div class="checkout-cart"{amp}gt; {amp}lt;div class="content"{amp}gt; {amp}lt;!-- contact form --{amp}gt; {amp}lt;div class="row"{amp}gt; {amp}lt;div class="col-md-4 col-md-offset-4"{amp}gt; {amp}lt;div class="form-group"{amp}gt; {amp}lt;label for="form_name"{amp}gt;Firstname *{amp}lt;/label{amp}gt; {amp}lt;input id="name" type="text" name="name" class="form-control" placeholder="Please enter your Name *"{amp}gt; {amp}lt;/div{amp}gt; {amp}lt;/div{amp}gt; {amp}lt;/div{amp}gt; {amp}lt;div class="row"{amp}gt; {amp}lt;div class="col-md-4 col-md-offset-4"{amp}gt; {amp}lt;div class="form-group"{amp}gt; {amp}lt;label for="form_lastname"{amp}gt;Mobile *{amp}lt;/label{amp}gt; {amp}lt;input id="mobile" type="text" name="mobile" class="form-control" placeholder="Please enter your Mobile# *"{amp}gt; {amp}lt;/div{amp}gt; {amp}lt;/div{amp}gt; {amp}lt;/div{amp}gt; {amp}lt;div class="row"{amp}gt; {amp}lt;div class="col-md-4 col-md-offset-4"{amp}gt; {amp}lt;div class="form-group"{amp}gt; {amp}lt;label for="form_lastname"{amp}gt;Email *{amp}lt;/label{amp}gt; {amp}lt;input id="email" type="email" name="email" class="form-control" placeholder="Please enter Email *"{amp}gt; {amp}lt;/div{amp}gt; {amp}lt;!-- {amp}lt;div id="error" style="text-align:center;display:none"{amp}gt;Fill all the textboxes{amp}lt;/div{amp}gt; --{amp}gt; {amp}lt;/div{amp}gt; {amp}lt;/div{amp}gt; {amp}lt;!-- End contact form --{amp}gt; {amp}lt;table class="table table-bordered table-striped"{amp}gt; {amp}lt;tr style="background-color:#00a1b4"{amp}gt; {amp}lt;th{amp}gt; Name {amp}lt;/th{amp}gt; {amp}lt;th{amp}gt; Products {amp}lt;/th{amp}gt; {amp}lt;th {amp}gt; QUANTITY {amp}lt;/th{amp}gt; {amp}lt;th{amp}gt; Per Item Price {amp}lt;/th{amp}gt; {amp}lt;th{amp}gt; Total Price {amp}lt;/th{amp}gt; {amp}lt;/tr{amp}gt; {amp}lt;tr class="category motherboard" data-value="motherboard"{amp}gt; {amp}lt;td{amp}gt; {amp}lt;span{amp}gt;Motherboard{amp}lt;/span{amp}gt; {amp}lt;/td{amp}gt; {amp}lt;td{amp}gt; {amp}lt;select name="motherboard" id="motherboard" style="min-width: 100%;" class="select" onchange="getPrice(event)"{amp}gt; {amp}lt;option value="0"{amp}gt;Select Motherboard{amp}lt;/option{amp}gt; {amp}lt;?php echo motherboard_brand($connect); ?{amp}gt; {amp}lt;/select{amp}gt; {amp}lt;/td{amp}gt; {amp}lt;!-- QUANTITY --{amp}gt; {amp}lt;td{amp}gt; {amp}lt;input type="number" min="0" name="email" class="quantity" oninput="setTotalPrice(event)"/{amp}gt; {amp}lt;/td{amp}gt; {amp}lt;!-- per item price --{amp}gt; {amp}lt;td{amp}gt; {amp}lt;input type="text" readonly class="unit-price" {amp}gt; {amp}lt;/td{amp}gt; {amp}lt;!-- Total Price --{amp}gt; {amp}lt;td{amp}gt; {amp}lt;input type="text" readonly class="total-price"{amp}gt; {amp}lt;/td{amp}gt; {amp}lt;/tr{amp}gt; {amp}lt;tr class="category processor" data-value="processor"{amp}gt; {amp}lt;td{amp}gt; {amp}lt;span{amp}gt;Processor{amp}lt;/span{amp}gt; {amp}lt;/td{amp}gt; {amp}lt;td{amp}gt; {amp}lt;select name="processor" id="processor" style="min-width: 100%;" class="select processors" onchange="getPrice(event)"{amp}gt; {amp}lt;option{amp}gt;Select Processor{amp}lt;/option{amp}gt; {amp}lt;!-- {amp}lt;?php echo processor_brand($connect); ?{amp}gt; --{amp}gt; {amp}lt;/select{amp}gt; {amp}lt;/td{amp}gt; {amp}lt;!-- QUANTITY --{amp}gt; {amp}lt;td{amp}gt; {amp}lt;input type="number" min="0" name="email" class="quantity" oninput="setTotalPrice(event)"/{amp}gt; {amp}lt;/td{amp}gt; {amp}lt;!-- per item price --{amp}gt; {amp}lt;td{amp}gt; {amp}lt;input type="text" readonly class="unit-price" {amp}gt; {amp}lt;/td{amp}gt; {amp}lt;!-- Total Price --{amp}gt; {amp}lt;td{amp}gt; {amp}lt;input type="text" readonly class="total-price"{amp}gt; {amp}lt;/td{amp}gt; {amp}lt;/tr{amp}gt; {amp}lt;!-- End Processor Section --{amp}gt; {amp}lt;!-- Start Ram Section --{amp}gt; {amp}lt;tr class="category ram" data-value="ram"{amp}gt; {amp}lt;td{amp}gt; {amp}lt;span{amp}gt;Ram{amp}lt;/span{amp}gt; {amp}lt;/td{amp}gt; {amp}lt;td{amp}gt; {amp}lt;select name="ram" id="rams" style="min-width: 100%;" class="select" onchange="getPriceRam(event)"{amp}gt; {amp}lt;option id="ram1st"{amp}gt;Select Ram{amp}lt;/option{amp}gt; {amp}lt;!-- {amp}lt;?php echo ram_brand($connect); ?{amp}gt; --{amp}gt; {amp}lt;/select{amp}gt; {amp}lt;/td{amp}gt; {amp}lt;!-- QUANTITY --{amp}gt; {amp}lt;td{amp}gt; {amp}lt;input type="number" maxlength="6" min="0" min="10" name="email" class="quantity" oninput="setTotalPrice(event)"/{amp}gt; {amp}lt;/td{amp}gt; {amp}lt;!-- per item price --{amp}gt; {amp}lt;br{amp}gt; {amp}lt;td{amp}gt; {amp}lt;input type="text" readonly class="unit-price" {amp}gt; {amp}lt;/td{amp}gt; {amp}lt;!-- Total Price --{amp}gt; {amp}lt;td{amp}gt; {amp}lt;input type="text" readonly class="total-price"{amp}gt; {amp}lt;/td{amp}gt; {amp}lt;/tr{amp}gt; {amp}lt;!-- End Ram Section --{amp}gt; {amp}lt;!-- Start harddisk Section --{amp}gt; {amp}lt;tr class="category harddisk" data-value="harddisk"{amp}gt; {amp}lt;td{amp}gt; {amp}lt;span{amp}gt;Harddisk{amp}lt;/span{amp}gt; {amp}lt;/td{amp}gt; {amp}lt;td{amp}gt; {amp}lt;select name="harddisk" id="" style="min-width: 100%;" class="select" onchange="getPrice(event)"{amp}gt; {amp}lt;option{amp}gt;Select Harddisk{amp}lt;/option{amp}gt; {amp}lt;?php echo harddisk_brand($connect); ?{amp}gt; {amp}lt;/select{amp}gt; {amp}lt;/td{amp}gt; {amp}lt;!-- QUANTITY --{amp}gt; {amp}lt;td{amp}gt; {amp}lt;input type="number" maxlength="6" min="0" min="10" name="email" class="quantity" oninput="setTotalPrice(event)"/{amp}gt; {amp}lt;/td{amp}gt; {amp}lt;!-- per item price --{amp}gt; {amp}lt;br{amp}gt; {amp}lt;td{amp}gt; {amp}lt;input type="text" readonly class="unit-price" {amp}gt; {amp}lt;/td{amp}gt; {amp}lt;!-- Total Price --{amp}gt; {amp}lt;td{amp}gt; {amp}lt;input type="text" readonly class="total-price"{amp}gt; {amp}lt;/td{amp}gt; {amp}lt;/tr{amp}gt; {amp}lt;!-- End Harddisk Section --{amp}gt; {amp}lt;tr{amp}gt; {amp}lt;td colspan="4" align="right"{amp}gt;{amp}lt;b{amp}gt;Total Price : {amp}lt;/b{amp}gt;{amp}lt;/td{amp}gt; {amp}lt;td id="TotalPrice"{amp}gt;{amp}lt;/td{amp}gt; {amp}lt;/tr{amp}gt; {amp}lt;/table{amp}gt; {amp}lt;/div{amp}gt; {amp}lt;/div{amp}gt; {amp}lt;hr class="offset-lg hidden-xs"{amp}gt; {amp}lt;div class="col-sm-12"{amp}gt; {amp}lt;hr class="offset-md"{amp}gt; {amp}lt;div class="row"{amp}gt; {amp}lt;div class="col-xs-6 col-md-4 col-md-offset-3"{amp}gt; {amp}lt;!-- onclick="submitQuote(event);" --{amp}gt; {amp}lt;button class="btn btn-primary pull-right" type="button" onclick="submitQuote(event);" {amp}gt;Submit{amp}lt;/button{amp}gt; {amp}lt;/div{amp}gt; {amp}lt;/div{amp}gt; {amp}lt;hr class="offset-md"{amp}gt; {amp}lt;/div{amp}gt; {amp}lt;/div{amp}gt; {amp}lt;/form{amp}gt; {amp}lt;/div{amp}gt; {amp}lt;hr class="offset-lg"{amp}gt; {amp}lt;hr class="offset-sm"{amp}gt; {amp}lt;?php // include("includes/footer.php"); include("includes/jsLinks.php"); ?{amp}gt; {amp}lt;!-- For Processor --{amp}gt; {amp}lt;script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"{amp}gt;{amp}lt;/script{amp}gt; {amp}lt;script type="text/javascript"{amp}gt; function getPrice(e){ e.preventDefault(); // grandtotal(); var id = $(e.target).val(); // console.log(id); // ;unitPrice.value let parent = e.target.parentNode.parentNode; console.log(parent); let parentt = e.target.parentNode; // $("#selector option:selected"); console.log(parentt); let category = parent.getAttribute("data-value"); // console.log(category); $.ajax({ url:"load_data.php", method:"POST", data:{id:id}, success:function(data){ // console.log(data); let unitPrice = parent.querySelector("input.unit-price"); // console.log(unitPrice); unitPrice.value = data; $(parent).attr("data-id", id); $(parent).attr("data-quantity", 1); if($('.select').find(":selected").val() == 0) { parent.querySelector("input.quantity").value = ""; parent.querySelector("input.total-price").value = null; } else{ parent.querySelector("input.quantity").value = 1; parent.querySelector("input.total-price").value =  data * 1; } grandtotal(); } }); } function setTotalPrice(e){ e.preventDefault(); // console.log(event.target); let parent = e.target.parentNode.parentNode; // console.log(parent); let unitPrice = parent.querySelector("input.unit-price").value; let quantity = parent.querySelector("input.quantity").value; $(parent).attr("data-quantity", quantity); parent.querySelector("input.total-price").value = ( unitPrice) * ( quantity); grandtotal(); } // Grand Total function grandtotal() { var sum=0; $('.total-price').each(function(){ var item_val=parseFloat($(this).val()); if(isNaN(item_val)){ item_val=0; } sum =item_val; $('#TotalPrice').html(sum.toFixed(2)); }); } $("#motherboard").change(function(){ var mid = $("#motherboard").val(); // console.log(mid); $.ajax({ url: 'processor_data.php', method: 'post', data: 'mid='   mid }).done(function(processors) { // console.log(processors); $('#processor').empty().append('{amp}lt;option{amp}gt;Select Processor{amp}lt;/option{amp}gt;'); processors = JSON.parse(processors); var htmll = ''; processors.forEach(function(processor) { htmll  = '{amp}lt;option value="'   processor.id   '"{amp}gt;'   processor.product_title   '{amp}lt;/option{amp}gt;'; }) $('#processor').append(htmll); }); }) function getPriceRam(e){ e.preventDefault(); grandtotal(); var id = $(e.target).val(); // console.log(id); let parent = e.target.parentNode.parentNode; // console.log(parent); let category = parent.getAttribute("data-value"); // console.log(category); $.ajax({ url:"load_dataram.php", method:"POST", data:{id:id}, success:function(data){ // console.log(data); let unitPrice = parent.querySelector("input.unit-price"); // console.log(unitPrice); unitPrice.value = data; $(parent).attr("data-id", id); $(parent).attr("data-quantity", 1); parent.querySelector("input.quantity").value = 1; parent.querySelector("input.total-price").value =  data * 1; grandtotal(); } }); } $("#rams").change(function(){ var ramid = $("#rams").val(); // console.log(ramid); }) $("#processor").change(function(){ var pid = $("#processor").val(); $.ajax({ url: 'data.php', method: 'post', data: 'pid='   pid }).done(function(data) { // console.log(data); $('#rams').empty().append('{amp}lt;option{amp}gt;Select Ram{amp}lt;/option{amp}gt;'); data = JSON.parse(data); var html = ''; data.forEach(function(value) { html  = '{amp}lt;option value="'   value.id   '"{amp}gt;'   value.product_title   '{amp}lt;/option{amp}gt;'; }) $('#rams').append(html); }); }) function getPriceRam(e){ e.preventDefault(); grandtotal(); var id = $(e.target).val(); // console.log(id); let parent = e.target.parentNode.parentNode; // console.log(parent); let category = parent.getAttribute("data-value"); // console.log(category); $.ajax({ url:"load_dataram.php", method:"POST", data:{id:id}, success:function(data){ // console.log(id); let unitPrice = parent.querySelector("input.unit-price"); // console.log(unitPrice); unitPrice.value = data; $(parent).attr("data-id", id); $(parent).attr("data-quantity", 1); parent.querySelector("input.quantity").value = 1; parent.querySelector("input.total-price").value =  data * 1; grandtotal(); } }); } $("#rams").change(function(){ var ramid = $("#rams").val(); // console.log(ramid); }) // insert into db function submitQuote(e){ let username = document.getElementById("name").value; let mobile = document.getElementById("mobile").value; let email = document.getElementById("email").value; // if (name.length {amp}lt; 1 || mobile.length {amp}lt; 1 || email.length {amp}lt; 1 ) { // alert('Contact field cannot be empty.'); // // return false; // } // if ((name==null || name=="") {amp}amp;{amp}amp; (mobile==null || mobile=="") {amp}amp;{amp}amp; (email==null || email=="")) // { // alert("Please Fillout all the fields!"); // return false; // } if (username == "") { $("#name").css("border", "2px solid red"); $("#name").focus(); } if (mobile == "") { $("#mobile").css("border", "2px solid red"); $("#mobile").focus(); } if (email == "") { $("#email").css("border", "2px solid red"); $("#email").focus(); } else{ let categories = document.querySelectorAll("tr.category"); let name = document.getElementById("name").value; let mobile = document.getElementById("mobile").value; let email = document.getElementById("email").value; // console.log(name); // console.log(mobile); // console.log(email); let items = []; // console.log(categories); Array.from(categories).forEach(category={amp}gt;{ let item = {}; item.id =   category.getAttribute("data-id"); item.quantity =   category.getAttribute("data-quantity"); if(item.id !== 0){ items.push(item); } }); // console.log(items); let data = JSON.stringify(items); console.log(data); $.ajax({ type: "POST", contentType: "application/json; charset=utf-8", dataType: "json", data: { data: data }, complete: function () { if(data=='[]') { alert("Please Select product"); } else { window.location.href = "reciept.php?dist="   data   "{amp}amp;name="   name   "{amp}amp;mobile="   mobile   "{amp}amp;email="   email; } } }); } } {amp}lt;/script{amp}gt; в {amp}lt;?php include("includes/headerLinks.php"); include("includes/nav.php"); // include("includes/db.php"); // include("includes/header.php"); $connect = mysqli_connect("localhost", "root", "", "onlinequotation"); function motherboard_brand($connect) { $output = ''; $sql = "SELECT * FROM products WHERE category='Motherboard' AND status='Active'"; $result = mysqli_query($connect, $sql); while($row = mysqli_fetch_array($result)) { $output .= '{amp}lt;option value="'.$row["id"].'"{amp}gt;'.$row["product_title"].'{amp}lt;/option{amp}gt;'; } return $output; } function processor_brand($connect) { $output = ''; $sql = "SELECT * FROM products WHERE category='Processor' AND status='Active'"; $result = mysqli_query($connect, $sql); while($row = mysqli_fetch_array($result)) { $output .= '{amp}lt;option value="'.$row["id"].'"{amp}gt;'.$row["product_title"].'{amp}lt;/option{amp}gt;'; } return $output; } // for ram function ram_brand($connect) { $output = ''; $sql = "SELECT * FROM products WHERE category='Ram' AND status='Active'"; $result = mysqli_query($connect, $sql); while($row = mysqli_fetch_array($result)) { $output .= '{amp}lt;option value="'.$row["id"].'"{amp}gt;'.$row["product_title"].'{amp}lt;/option{amp}gt;'; } return $output; } // For Hardisk function harddisk_brand($connect) { $output = ''; $sql = "SELECT * FROM products WHERE category='Hard-disk' AND status='Active'"; $result = mysqli_query($connect, $sql); while($row = mysqli_fetch_array($result)) { $output .= '{amp}lt;option value="'.$row["id"].'"{amp}gt;'.$row["product_title"].'{amp}lt;/option{amp}gt;'; } return $output; } ?{amp}gt; {amp}lt;hr class="offset-top"{amp}gt; {amp}lt;div class="white"{amp}gt; {amp}lt;div class="container checkout"{amp}gt; {amp}lt;h1{amp}gt;Quotation Generator{amp}lt;/h1{amp}gt; {amp}lt;hr class="offset-sm"{amp}gt; {amp}lt;/div{amp}gt; {amp}lt;/div{amp}gt; {amp}lt;hr class="offset-md"{amp}gt; {amp}lt;div class="container checkout"{amp}gt; {amp}lt;form method="POST" name="myForm"{amp}gt; {amp}lt;div class="row"{amp}gt; {amp}lt;div class="col-md-12 white" style="border-radius:30px"{amp}gt; {amp}lt;div class="checkout-cart"{amp}gt; {amp}lt;div class="content"{amp}gt; {amp}lt;!-- contact form --{amp}gt; {amp}lt;div class="row"{amp}gt; {amp}lt;div class="col-md-4 col-md-offset-4"{amp}gt; {amp}lt;div class="form-group"{amp}gt; {amp}lt;label for="form_name"{amp}gt;Firstname *{amp}lt;/label{amp}gt; {amp}lt;input id="name" type="text" name="name" class="form-control" placeholder="Please enter your Name *"{amp}gt; {amp}lt;/div{amp}gt; {amp}lt;/div{amp}gt; {amp}lt;/div{amp}gt; {amp}lt;div class="row"{amp}gt; {amp}lt;div class="col-md-4 col-md-offset-4"{amp}gt; {amp}lt;div class="form-group"{amp}gt; {amp}lt;label for="form_lastname"{amp}gt;Mobile *{amp}lt;/label{amp}gt; {amp}lt;input id="mobile" type="text" name="mobile" class="form-control" placeholder="Please enter your Mobile# *"{amp}gt; {amp}lt;/div{amp}gt; {amp}lt;/div{amp}gt; {amp}lt;/div{amp}gt; {amp}lt;div class="row"{amp}gt; {amp}lt;div class="col-md-4 col-md-offset-4"{amp}gt; {amp}lt;div class="form-group"{amp}gt; {amp}lt;label for="form_lastname"{amp}gt;Email *{amp}lt;/label{amp}gt; {amp}lt;input id="email" type="email" name="email" class="form-control" placeholder="Please enter Email *"{amp}gt; {amp}lt;/div{amp}gt; {amp}lt;!-- {amp}lt;div id="error" style="text-align:center;display:none"{amp}gt;Fill all the textboxes{amp}lt;/div{amp}gt; --{amp}gt; {amp}lt;/div{amp}gt; {amp}lt;/div{amp}gt; {amp}lt;!-- End contact form --{amp}gt; {amp}lt;table class="table table-bordered table-striped"{amp}gt; {amp}lt;tr style="background-color:#00a1b4"{amp}gt; {amp}lt;th{amp}gt; Name {amp}lt;/th{amp}gt; {amp}lt;th{amp}gt; Products {amp}lt;/th{amp}gt; {amp}lt;th {amp}gt; QUANTITY {amp}lt;/th{amp}gt; {amp}lt;th{amp}gt; Per Item Price {amp}lt;/th{amp}gt; {amp}lt;th{amp}gt; Total Price {amp}lt;/th{amp}gt; {amp}lt;/tr{amp}gt; {amp}lt;tr class="category motherboard" data-value="motherboard"{amp}gt; {amp}lt;td{amp}gt; {amp}lt;span{amp}gt;Motherboard{amp}lt;/span{amp}gt; {amp}lt;/td{amp}gt; {amp}lt;td{amp}gt; {amp}lt;select name="motherboard" id="motherboard" style="min-width: 100%;" class="select" onchange="getPrice(event)"{amp}gt; {amp}lt;option value="0"{amp}gt;Select Motherboard{amp}lt;/option{amp}gt; {amp}lt;?php echo motherboard_brand($connect); ?{amp}gt; {amp}lt;/select{amp}gt; {amp}lt;/td{amp}gt; {amp}lt;!-- QUANTITY --{amp}gt; {amp}lt;td{amp}gt; {amp}lt;input type="number" min="0" name="email" class="quantity" oninput="setTotalPrice(event)"/{amp}gt; {amp}lt;/td{amp}gt; {amp}lt;!-- per item price --{amp}gt; {amp}lt;td{amp}gt; {amp}lt;input type="text" readonly class="unit-price" {amp}gt; {amp}lt;/td{amp}gt; {amp}lt;!-- Total Price --{amp}gt; {amp}lt;td{amp}gt; {amp}lt;input type="text" readonly class="total-price"{amp}gt; {amp}lt;/td{amp}gt; {amp}lt;/tr{amp}gt; {amp}lt;tr class="category processor" data-value="processor"{amp}gt; {amp}lt;td{amp}gt; {amp}lt;span{amp}gt;Processor{amp}lt;/span{amp}gt; {amp}lt;/td{amp}gt; {amp}lt;td{amp}gt; {amp}lt;select name="processor" id="processor" style="min-width: 100%;" class="select processors" onchange="getPrice(event)"{amp}gt; {amp}lt;option{amp}gt;Select Processor{amp}lt;/option{amp}gt; {amp}lt;!-- {amp}lt;?php echo processor_brand($connect); ?{amp}gt; --{amp}gt; {amp}lt;/select{amp}gt; {amp}lt;/td{amp}gt; {amp}lt;!-- QUANTITY --{amp}gt; {amp}lt;td{amp}gt; {amp}lt;input type="number" min="0" name="email" class="quantity" oninput="setTotalPrice(event)"/{amp}gt; {amp}lt;/td{amp}gt; {amp}lt;!-- per item price --{amp}gt; {amp}lt;td{amp}gt; {amp}lt;input type="text" readonly class="unit-price" {amp}gt; {amp}lt;/td{amp}gt; {amp}lt;!-- Total Price --{amp}gt; {amp}lt;td{amp}gt; {amp}lt;input type="text" readonly class="total-price"{amp}gt; {amp}lt;/td{amp}gt; {amp}lt;/tr{amp}gt; {amp}lt;!-- End Processor Section --{amp}gt; {amp}lt;!-- Start Ram Section --{amp}gt; {amp}lt;tr class="category ram" data-value="ram"{amp}gt; {amp}lt;td{amp}gt; {amp}lt;span{amp}gt;Ram{amp}lt;/span{amp}gt; {amp}lt;/td{amp}gt; {amp}lt;td{amp}gt; {amp}lt;select name="ram" id="rams" style="min-width: 100%;" class="select" onchange="getPriceRam(event)"{amp}gt; {amp}lt;option id="ram1st"{amp}gt;Select Ram{amp}lt;/option{amp}gt; {amp}lt;!-- {amp}lt;?php echo ram_brand($connect); ?{amp}gt; --{amp}gt; {amp}lt;/select{amp}gt; {amp}lt;/td{amp}gt; {amp}lt;!-- QUANTITY --{amp}gt; {amp}lt;td{amp}gt; {amp}lt;input type="number" maxlength="6" min="0" min="10" name="email" class="quantity" oninput="setTotalPrice(event)"/{amp}gt; {amp}lt;/td{amp}gt; {amp}lt;!-- per item price --{amp}gt; {amp}lt;br{amp}gt; {amp}lt;td{amp}gt; {amp}lt;input type="text" readonly class="unit-price" {amp}gt; {amp}lt;/td{amp}gt; {amp}lt;!-- Total Price --{amp}gt; {amp}lt;td{amp}gt; {amp}lt;input type="text" readonly class="total-price"{amp}gt; {amp}lt;/td{amp}gt; {amp}lt;/tr{amp}gt; {amp}lt;!-- End Ram Section --{amp}gt; {amp}lt;!-- Start harddisk Section --{amp}gt; {amp}lt;tr class="category harddisk" data-value="harddisk"{amp}gt; {amp}lt;td{amp}gt; {amp}lt;span{amp}gt;Harddisk{amp}lt;/span{amp}gt; {amp}lt;/td{amp}gt; {amp}lt;td{amp}gt; {amp}lt;select name="harddisk" id="" style="min-width: 100%;" class="select" onchange="getPrice(event)"{amp}gt; {amp}lt;option{amp}gt;Select Harddisk{amp}lt;/option{amp}gt; {amp}lt;?php echo harddisk_brand($connect); ?{amp}gt; {amp}lt;/select{amp}gt; {amp}lt;/td{amp}gt; {amp}lt;!-- QUANTITY --{amp}gt; {amp}lt;td{amp}gt; {amp}lt;input type="number" maxlength="6" min="0" min="10" name="email" class="quantity" oninput="setTotalPrice(event)"/{amp}gt; {amp}lt;/td{amp}gt; {amp}lt;!-- per item price --{amp}gt; {amp}lt;br{amp}gt; {amp}lt;td{amp}gt; {amp}lt;input type="text" readonly class="unit-price" {amp}gt; {amp}lt;/td{amp}gt; {amp}lt;!-- Total Price --{amp}gt; {amp}lt;td{amp}gt; {amp}lt;input type="text" readonly class="total-price"{amp}gt; {amp}lt;/td{amp}gt; {amp}lt;/tr{amp}gt; {amp}lt;!-- End Harddisk Section --{amp}gt; {amp}lt;tr{amp}gt; {amp}lt;td colspan="4" align="right"{amp}gt;{amp}lt;b{amp}gt;Total Price : {amp}lt;/b{amp}gt;{amp}lt;/td{amp}gt; {amp}lt;td id="TotalPrice"{amp}gt;{amp}lt;/td{amp}gt; {amp}lt;/tr{amp}gt; {amp}lt;/table{amp}gt; {amp}lt;/div{amp}gt; {amp}lt;/div{amp}gt; {amp}lt;hr class="offset-lg hidden-xs"{amp}gt; {amp}lt;div class="col-sm-12"{amp}gt; {amp}lt;hr class="offset-md"{amp}gt; {amp}lt;div class="row"{amp}gt; {amp}lt;div class="col-xs-6 col-md-4 col-md-offset-3"{amp}gt; {amp}lt;!-- onclick="submitQuote(event);" --{amp}gt; {amp}lt;button class="btn btn-primary pull-right" type="button" onclick="submitQuote(event);" {amp}gt;Submit{amp}lt;/button{amp}gt; {amp}lt;/div{amp}gt; {amp}lt;/div{amp}gt; {amp}lt;hr class="offset-md"{amp}gt; {amp}lt;/div{amp}gt; {amp}lt;/div{amp}gt; {amp}lt;/form{amp}gt; {amp}lt;/div{amp}gt; {amp}lt;hr class="offset-lg"{amp}gt; {amp}lt;hr class="offset-sm"{amp}gt; {amp}lt;?php // include("includes/footer.php"); include("includes/jsLinks.php"); ?{amp}gt; {amp}lt;!-- For Processor --{amp}gt; {amp}lt;script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"{amp}gt;{amp}lt;/script{amp}gt; {amp}lt;script type="text/javascript"{amp}gt; function getPrice(e){ e.preventDefault(); // grandtotal(); var id = $(e.target).val(); // console.log(id); // ;unitPrice.value let parent = e.target.parentNode.parentNode; console.log(parent); let parentt = e.target.parentNode; // $("#selector option:selected"); console.log(parentt); let category = parent.getAttribute("data-value"); // console.log(category); $.ajax({ url:"load_data.php", method:"POST", data:{id:id}, success:function(data){ // console.log(data); let unitPrice = parent.querySelector("input.unit-price"); // console.log(unitPrice); unitPrice.value = data; $(parent).attr("data-id", id); $(parent).attr("data-quantity", 1); if($('.select').find(":selected").val() == 0) { parent.querySelector("input.quantity").value = ""; parent.querySelector("input.total-price").value = null; } else{ parent.querySelector("input.quantity").value = 1; parent.querySelector("input.total-price").value =  data * 1; } grandtotal(); } }); } function setTotalPrice(e){ e.preventDefault(); // console.log(event.target); let parent = e.target.parentNode.parentNode; // console.log(parent); let unitPrice = parent.querySelector("input.unit-price").value; let quantity = parent.querySelector("input.quantity").value; $(parent).attr("data-quantity", quantity); parent.querySelector("input.total-price").value = ( unitPrice) * ( quantity); grandtotal(); } // Grand Total function grandtotal() { var sum=0; $('.total-price').each(function(){ var item_val=parseFloat($(this).val()); if(isNaN(item_val)){ item_val=0; } sum =item_val; $('#TotalPrice').html(sum.toFixed(2)); }); } $("#motherboard").change(function(){ var mid = $("#motherboard").val(); // console.log(mid); $.ajax({ url: 'processor_data.php', method: 'post', data: 'mid='   mid }).done(function(processors) { // console.log(processors); $('#processor').empty().append('{amp}lt;option{amp}gt;Select Processor{amp}lt;/option{amp}gt;'); processors = JSON.parse(processors); var htmll = ''; processors.forEach(function(processor) { htmll  = '{amp}lt;option value="'   processor.id   '"{amp}gt;'   processor.product_title   '{amp}lt;/option{amp}gt;'; }) $('#processor').append(htmll); }); }) function getPriceRam(e){ e.preventDefault(); grandtotal(); var id = $(e.target).val(); // console.log(id); let parent = e.target.parentNode.parentNode; // console.log(parent); let category = parent.getAttribute("data-value"); // console.log(category); $.ajax({ url:"load_dataram.php", method:"POST", data:{id:id}, success:function(data){ // console.log(data); let unitPrice = parent.querySelector("input.unit-price"); // console.log(unitPrice); unitPrice.value = data; $(parent).attr("data-id", id); $(parent).attr("data-quantity", 1); parent.querySelector("input.quantity").value = 1; parent.querySelector("input.total-price").value =  data * 1; grandtotal(); } }); } $("#rams").change(function(){ var ramid = $("#rams").val(); // console.log(ramid); }) $("#processor").change(function(){ var pid = $("#processor").val(); $.ajax({ url: 'data.php', method: 'post', data: 'pid='   pid }).done(function(data) { // console.log(data); $('#rams').empty().append('{amp}lt;option{amp}gt;Select Ram{amp}lt;/option{amp}gt;'); data = JSON.parse(data); var html = ''; data.forEach(function(value) { html  = '{amp}lt;option value="'   value.id   '"{amp}gt;'   value.product_title   '{amp}lt;/option{amp}gt;'; }) $('#rams').append(html); }); }) function getPriceRam(e){ e.preventDefault(); grandtotal(); var id = $(e.target).val(); // console.log(id); let parent = e.target.parentNode.parentNode; // console.log(parent); let category = parent.getAttribute("data-value"); // console.log(category); $.ajax({ url:"load_dataram.php", method:"POST", data:{id:id}, success:function(data){ // console.log(id); let unitPrice = parent.querySelector("input.unit-price"); // console.log(unitPrice); unitPrice.value = data; $(parent).attr("data-id", id); $(parent).attr("data-quantity", 1); parent.querySelector("input.quantity").value = 1; parent.querySelector("input.total-price").value =  data * 1; grandtotal(); } }); } $("#rams").change(function(){ var ramid = $("#rams").val(); // console.log(ramid); }) // insert into db function submitQuote(e){ let username = document.getElementById("name").value; let mobile = document.getElementById("mobile").value; let email = document.getElementById("email").value; // if (name.length {amp}lt; 1 || mobile.length {amp}lt; 1 || email.length {amp}lt; 1 ) { // alert('Contact field cannot be empty.'); // // return false; // } // if ((name==null || name=="") {amp}amp;{amp}amp; (mobile==null || mobile=="") {amp}amp;{amp}amp; (email==null || email=="")) // { // alert("Please Fillout all the fields!"); // return false; // } if (username == "") { $("#name").css("border", "2px solid red"); $("#name").focus(); } if (mobile == "") { $("#mobile").css("border", "2px solid red"); $("#mobile").focus(); } if (email == "") { $("#email").css("border", "2px solid red"); $("#email").focus(); } else{ let categories = document.querySelectorAll("tr.category"); let name = document.getElementById("name").value; let mobile = document.getElementById("mobile").value; let email = document.getElementById("email").value; // console.log(name); // console.log(mobile); // console.log(email); let items = []; // console.log(categories); Array.from(categories).forEach(category={amp}gt;{ let item = {}; item.id =   category.getAttribute("data-id"); item.quantity =   category.getAttribute("data-quantity"); if(item.id !== 0){ items.push(item); } }); // console.log(items); let data = JSON.stringify(items); console.log(data); $.ajax({ type: "POST", contentType: "application/json; charset=utf-8", dataType: "json", data: { data: data }, complete: function () { if(data=='[]') { alert("Please Select product"); } else { window.location.href = "reciept.php?dist="   data   "{amp}amp;name="   name   "{amp}amp;mobile="   mobile   "{amp}amp;email="   email; } } }); } } {amp}lt;/script{amp}gt; в {amp}lt;?php include("includes/headerLinks.php"); include("includes/nav.php"); // include("includes/db.php"); // include("includes/header.php"); $connect = mysqli_connect("localhost", "root", "", "onlinequotation"); function motherboard_brand($connect) { $output = ''; $sql = "SELECT * FROM products WHERE category='Motherboard' AND status='Active'"; $result = mysqli_query($connect, $sql); while($row = mysqli_fetch_array($result)) { $output .= '{amp}lt;option value="'.$row["id"].'"{amp}gt;'.$row["product_title"].'{amp}lt;/option{amp}gt;'; } return $output; } function processor_brand($connect) { $output = ''; $sql = "SELECT * FROM products WHERE category='Processor' AND status='Active'"; $result = mysqli_query($connect, $sql); while($row = mysqli_fetch_array($result)) { $output .= '{amp}lt;option value="'.$row["id"].'"{amp}gt;'.$row["product_title"].'{amp}lt;/option{amp}gt;'; } return $output; } // for ram function ram_brand($connect) { $output = ''; $sql = "SELECT * FROM products WHERE category='Ram' AND status='Active'"; $result = mysqli_query($connect, $sql); while($row = mysqli_fetch_array($result)) { $output .= '{amp}lt;option value="'.$row["id"].'"{amp}gt;'.$row["product_title"].'{amp}lt;/option{amp}gt;'; } return $output; } // For Hardisk function harddisk_brand($connect) { $output = ''; $sql = "SELECT * FROM products WHERE category='Hard-disk' AND status='Active'"; $result = mysqli_query($connect, $sql); while($row = mysqli_fetch_array($result)) { $output .= '{amp}lt;option value="'.$row["id"].'"{amp}gt;'.$row["product_title"].'{amp}lt;/option{amp}gt;'; } return $output; } ?{amp}gt; {amp}lt;hr class="offset-top"{amp}gt; {amp}lt;div class="white"{amp}gt; {amp}lt;div class="container checkout"{amp}gt; {amp}lt;h1{amp}gt;Quotation Generator{amp}lt;/h1{amp}gt; {amp}lt;hr class="offset-sm"{amp}gt; {amp}lt;/div{amp}gt; {amp}lt;/div{amp}gt; {amp}lt;hr class="offset-md"{amp}gt; {amp}lt;div class="container checkout"{amp}gt; {amp}lt;form method="POST" name="myForm"{amp}gt; {amp}lt;div class="row"{amp}gt; {amp}lt;div class="col-md-12 white" style="border-radius:30px"{amp}gt; {amp}lt;div class="checkout-cart"{amp}gt; {amp}lt;div class="content"{amp}gt; {amp}lt;!-- contact form --{amp}gt; {amp}lt;div class="row"{amp}gt; {amp}lt;div class="col-md-4 col-md-offset-4"{amp}gt; {amp}lt;div class="form-group"{amp}gt; {amp}lt;label for="form_name"{amp}gt;Firstname *{amp}lt;/label{amp}gt; {amp}lt;input id="name" type="text" name="name" class="form-control" placeholder="Please enter your Name *"{amp}gt; {amp}lt;/div{amp}gt; {amp}lt;/div{amp}gt; {amp}lt;/div{amp}gt; {amp}lt;div class="row"{amp}gt; {amp}lt;div class="col-md-4 col-md-offset-4"{amp}gt; {amp}lt;div class="form-group"{amp}gt; {amp}lt;label for="form_lastname"{amp}gt;Mobile *{amp}lt;/label{amp}gt; {amp}lt;input id="mobile" type="text" name="mobile" class="form-control" placeholder="Please enter your Mobile# *"{amp}gt; {amp}lt;/div{amp}gt; {amp}lt;/div{amp}gt; {amp}lt;/div{amp}gt; {amp}lt;div class="row"{amp}gt; {amp}lt;div class="col-md-4 col-md-offset-4"{amp}gt; {amp}lt;div class="form-group"{amp}gt; {amp}lt;label for="form_lastname"{amp}gt;Email *{amp}lt;/label{amp}gt; {amp}lt;input id="email" type="email" name="email" class="form-control" placeholder="Please enter Email *"{amp}gt; {amp}lt;/div{amp}gt; {amp}lt;!-- {amp}lt;div id="error" style="text-align:center;display:none"{amp}gt;Fill all the textboxes{amp}lt;/div{amp}gt; --{amp}gt; {amp}lt;/div{amp}gt; {amp}lt;/div{amp}gt; {amp}lt;!-- End contact form --{amp}gt; {amp}lt;table class="table table-bordered table-striped"{amp}gt; {amp}lt;tr style="background-color:#00a1b4"{amp}gt; {amp}lt;th{amp}gt; Name {amp}lt;/th{amp}gt; {amp}lt;th{amp}gt; Products {amp}lt;/th{amp}gt; {amp}lt;th {amp}gt; QUANTITY {amp}lt;/th{amp}gt; {amp}lt;th{amp}gt; Per Item Price {amp}lt;/th{amp}gt; {amp}lt;th{amp}gt; Total Price {amp}lt;/th{amp}gt; {amp}lt;/tr{amp}gt; {amp}lt;tr class="category motherboard" data-value="motherboard"{amp}gt; {amp}lt;td{amp}gt; {amp}lt;span{amp}gt;Motherboard{amp}lt;/span{amp}gt; {amp}lt;/td{amp}gt; {amp}lt;td{amp}gt; {amp}lt;select name="motherboard" id="motherboard" style="min-width: 100%;" class="select" onchange="getPrice(event)"{amp}gt; {amp}lt;option value="0"{amp}gt;Select Motherboard{amp}lt;/option{amp}gt; {amp}lt;?php echo motherboard_brand($connect); ?{amp}gt; {amp}lt;/select{amp}gt; {amp}lt;/td{amp}gt; {amp}lt;!-- QUANTITY --{amp}gt; {amp}lt;td{amp}gt; {amp}lt;input type="number" min="0" name="email" class="quantity" oninput="setTotalPrice(event)"/{amp}gt; {amp}lt;/td{amp}gt; {amp}lt;!-- per item price --{amp}gt; {amp}lt;td{amp}gt; {amp}lt;input type="text" readonly class="unit-price" {amp}gt; {amp}lt;/td{amp}gt; {amp}lt;!-- Total Price --{amp}gt; {amp}lt;td{amp}gt; {amp}lt;input type="text" readonly class="total-price"{amp}gt; {amp}lt;/td{amp}gt; {amp}lt;/tr{amp}gt; {amp}lt;tr class="category processor" data-value="processor"{amp}gt; {amp}lt;td{amp}gt; {amp}lt;span{amp}gt;Processor{amp}lt;/span{amp}gt; {amp}lt;/td{amp}gt; {amp}lt;td{amp}gt; {amp}lt;select name="processor" id="processor" style="min-width: 100%;" class="select processors" onchange="getPrice(event)"{amp}gt; {amp}lt;option{amp}gt;Select Processor{amp}lt;/option{amp}gt; {amp}lt;!-- {amp}lt;?php echo processor_brand($connect); ?{amp}gt; --{amp}gt; {amp}lt;/select{amp}gt; {amp}lt;/td{amp}gt; {amp}lt;!-- QUANTITY --{amp}gt; {amp}lt;td{amp}gt; {amp}lt;input type="number" min="0" name="email" class="quantity" oninput="setTotalPrice(event)"/{amp}gt; {amp}lt;/td{amp}gt; {amp}lt;!-- per item price --{amp}gt; {amp}lt;td{amp}gt; {amp}lt;input type="text" readonly class="unit-price" {amp}gt; {amp}lt;/td{amp}gt; {amp}lt;!-- Total Price --{amp}gt; {amp}lt;td{amp}gt; {amp}lt;input type="text" readonly class="total-price"{amp}gt; {amp}lt;/td{amp}gt; {amp}lt;/tr{amp}gt; {amp}lt;!-- End Processor Section --{amp}gt; {amp}lt;!-- Start Ram Section --{amp}gt; {amp}lt;tr class="category ram" data-value="ram"{amp}gt; {amp}lt;td{amp}gt; {amp}lt;span{amp}gt;Ram{amp}lt;/span{amp}gt; {amp}lt;/td{amp}gt; {amp}lt;td{amp}gt; {amp}lt;select name="ram" id="rams" style="min-width: 100%;" class="select" onchange="getPriceRam(event)"{amp}gt; {amp}lt;option id="ram1st"{amp}gt;Select Ram{amp}lt;/option{amp}gt; {amp}lt;!-- {amp}lt;?php echo ram_brand($connect); ?{amp}gt; --{amp}gt; {amp}lt;/select{amp}gt; {amp}lt;/td{amp}gt; {amp}lt;!-- QUANTITY --{amp}gt; {amp}lt;td{amp}gt; {amp}lt;input type="number" maxlength="6" min="0" min="10" name="email" class="quantity" oninput="setTotalPrice(event)"/{amp}gt; {amp}lt;/td{amp}gt; {amp}lt;!-- per item price --{amp}gt; {amp}lt;br{amp}gt; {amp}lt;td{amp}gt; {amp}lt;input type="text" readonly class="unit-price" {amp}gt; {amp}lt;/td{amp}gt; {amp}lt;!-- Total Price --{amp}gt; {amp}lt;td{amp}gt; {amp}lt;input type="text" readonly class="total-price"{amp}gt; {amp}lt;/td{amp}gt; {amp}lt;/tr{amp}gt; {amp}lt;!-- End Ram Section --{amp}gt; {amp}lt;!-- Start harddisk Section --{amp}gt; {amp}lt;tr class="category harddisk" data-value="harddisk"{amp}gt; {amp}lt;td{amp}gt; {amp}lt;span{amp}gt;Harddisk{amp}lt;/span{amp}gt; {amp}lt;/td{amp}gt; {amp}lt;td{amp}gt; {amp}lt;select name="harddisk" id="" style="min-width: 100%;" class="select" onchange="getPrice(event)"{amp}gt; {amp}lt;option{amp}gt;Select Harddisk{amp}lt;/option{amp}gt; {amp}lt;?php echo harddisk_brand($connect); ?{amp}gt; {amp}lt;/select{amp}gt; {amp}lt;/td{amp}gt; {amp}lt;!-- QUANTITY --{amp}gt; {amp}lt;td{amp}gt; {amp}lt;input type="number" maxlength="6" min="0" min="10" name="email" class="quantity" oninput="setTotalPrice(event)"/{amp}gt; {amp}lt;/td{amp}gt; {amp}lt;!-- per item price --{amp}gt; {amp}lt;br{amp}gt; {amp}lt;td{amp}gt; {amp}lt;input type="text" readonly class="unit-price" {amp}gt; {amp}lt;/td{amp}gt; {amp}lt;!-- Total Price --{amp}gt; {amp}lt;td{amp}gt; {amp}lt;input type="text" readonly class="total-price"{amp}gt; {amp}lt;/td{amp}gt; {amp}lt;/tr{amp}gt; {amp}lt;!-- End Harddisk Section --{amp}gt; {amp}lt;tr{amp}gt; {amp}lt;td colspan="4" align="right"{amp}gt;{amp}lt;b{amp}gt;Total Price : {amp}lt;/b{amp}gt;{amp}lt;/td{amp}gt; {amp}lt;td id="TotalPrice"{amp}gt;{amp}lt;/td{amp}gt; {amp}lt;/tr{amp}gt; {amp}lt;/table{amp}gt; {amp}lt;/div{amp}gt; {amp}lt;/div{amp}gt; {amp}lt;hr class="offset-lg hidden-xs"{amp}gt; {amp}lt;div class="col-sm-12"{amp}gt; {amp}lt;hr class="offset-md"{amp}gt; {amp}lt;div class="row"{amp}gt; {amp}lt;div class="col-xs-6 col-md-4 col-md-offset-3"{amp}gt; {amp}lt;!-- onclick="submitQuote(event);" --{amp}gt; {amp}lt;button class="btn btn-primary pull-right" type="button" onclick="submitQuote(event);" {amp}gt;Submit{amp}lt;/button{amp}gt; {amp}lt;/div{amp}gt; {amp}lt;/div{amp}gt; {amp}lt;hr class="offset-md"{amp}gt; {amp}lt;/div{amp}gt; {amp}lt;/div{amp}gt; {amp}lt;/form{amp}gt; {amp}lt;/div{amp}gt; {amp}lt;hr class="offset-lg"{amp}gt; {amp}lt;hr class="offset-sm"{amp}gt; {amp}lt;?php // include("includes/footer.php"); include("includes/jsLinks.php"); ?{amp}gt; {amp}lt;!-- For Processor --{amp}gt; {amp}lt;script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"{amp}gt;{amp}lt;/script{amp}gt; {amp}lt;script type="text/javascript"{amp}gt; function getPrice(e){ e.preventDefault(); // grandtotal(); var id = $(e.target).val(); // console.log(id); // ;unitPrice.value let parent = e.target.parentNode.parentNode; console.log(parent); let parentt = e.target.parentNode; // $("#selector option:selected"); console.log(parentt); let category = parent.getAttribute("data-value"); // console.log(category); $.ajax({ url:"load_data.php", method:"POST", data:{id:id}, success:function(data){ // console.log(data); let unitPrice = parent.querySelector("input.unit-price"); // console.log(unitPrice); unitPrice.value = data; $(parent).attr("data-id", id); $(parent).attr("data-quantity", 1); if($('.select').find(":selected").val() == 0) { parent.querySelector("input.quantity").value = ""; parent.querySelector("input.total-price").value = null; } else{ parent.querySelector("input.quantity").value = 1; parent.querySelector("input.total-price").value =  data * 1; } grandtotal(); } }); } function setTotalPrice(e){ e.preventDefault(); // console.log(event.target); let parent = e.target.parentNode.parentNode; // console.log(parent); let unitPrice = parent.querySelector("input.unit-price").value; let quantity = parent.querySelector("input.quantity").value; $(parent).attr("data-quantity", quantity); parent.querySelector("input.total-price").value = ( unitPrice) * ( quantity); grandtotal(); } // Grand Total function grandtotal() { var sum=0; $('.total-price').each(function(){ var item_val=parseFloat($(this).val()); if(isNaN(item_val)){ item_val=0; } sum =item_val; $('#TotalPrice').html(sum.toFixed(2)); }); } $("#motherboard").change(function(){ var mid = $("#motherboard").val(); // console.log(mid); $.ajax({ url: 'processor_data.php', method: 'post', data: 'mid='   mid }).done(function(processors) { // console.log(processors); $('#processor').empty().append('{amp}lt;option{amp}gt;Select Processor{amp}lt;/option{amp}gt;'); processors = JSON.parse(processors); var htmll = ''; processors.forEach(function(processor) { htmll  = '{amp}lt;option value="'   processor.id   '"{amp}gt;'   processor.product_title   '{amp}lt;/option{amp}gt;'; }) $('#processor').append(htmll); }); }) function getPriceRam(e){ e.preventDefault(); grandtotal(); var id = $(e.target).val(); // console.log(id); let parent = e.target.parentNode.parentNode; // console.log(parent); let category = parent.getAttribute("data-value"); // console.log(category); $.ajax({ url:"load_dataram.php", method:"POST", data:{id:id}, success:function(data){ // console.log(data); let unitPrice = parent.querySelector("input.unit-price"); // console.log(unitPrice); unitPrice.value = data; $(parent).attr("data-id", id); $(parent).attr("data-quantity", 1); parent.querySelector("input.quantity").value = 1; parent.querySelector("input.total-price").value =  data * 1; grandtotal(); } }); } $("#rams").change(function(){ var ramid = $("#rams").val(); // console.log(ramid); }) $("#processor").change(function(){ var pid = $("#processor").val(); $.ajax({ url: 'data.php', method: 'post', data: 'pid='   pid }).done(function(data) { // console.log(data); $('#rams').empty().append('{amp}lt;option{amp}gt;Select Ram{amp}lt;/option{amp}gt;'); data = JSON.parse(data); var html = ''; data.forEach(function(value) { html  = '{amp}lt;option value="'   value.id   '"{amp}gt;'   value.product_title   '{amp}lt;/option{amp}gt;'; }) $('#rams').append(html); }); }) function getPriceRam(e){ e.preventDefault(); grandtotal(); var id = $(e.target).val(); // console.log(id); let parent = e.target.parentNode.parentNode; // console.log(parent); let category = parent.getAttribute("data-value"); // console.log(category); $.ajax({ url:"load_dataram.php", method:"POST", data:{id:id}, success:function(data){ // console.log(id); let unitPrice = parent.querySelector("input.unit-price"); // console.log(unitPrice); unitPrice.value = data; $(parent).attr("data-id", id); $(parent).attr("data-quantity", 1); parent.querySelector("input.quantity").value = 1; parent.querySelector("input.total-price").value =  data * 1; grandtotal(); } }); } $("#rams").change(function(){ var ramid = $("#rams").val(); // console.log(ramid); }) // insert into db function submitQuote(e){ let username = document.getElementById("name").value; let mobile = document.getElementById("mobile").value; let email = document.getElementById("email").value; // if (name.length {amp}lt; 1 || mobile.length {amp}lt; 1 || email.length {amp}lt; 1 ) { // alert('Contact field cannot be empty.'); // // return false; // } // if ((name==null || name=="") {amp}amp;{amp}amp; (mobile==null || mobile=="") {amp}amp;{amp}amp; (email==null || email=="")) // { // alert("Please Fillout all the fields!"); // return false; // } if (username == "") { $("#name").css("border", "2px solid red"); $("#name").focus(); } if (mobile == "") { $("#mobile").css("border", "2px solid red"); $("#mobile").focus(); } if (email == "") { $("#email").css("border", "2px solid red"); $("#email").focus(); } else{ let categories = document.querySelectorAll("tr.category"); let name = document.getElementById("name").value; let mobile = document.getElementById("mobile").value; let email = document.getElementById("email").value; // console.log(name); // console.log(mobile); // console.log(email); let items = []; // console.log(categories); Array.from(categories).forEach(category={amp}gt;{ let item = {}; item.id =   category.getAttribute("data-id"); item.quantity =   category.getAttribute("data-quantity"); if(item.id !== 0){ items.push(item); } }); // console.log(items); let data = JSON.stringify(items); console.log(data); $.ajax({ type: "POST", contentType: "application/json; charset=utf-8", dataType: "json", data: { data: data }, complete: function () { if(data=='[]') { alert("Please Select product"); } else { window.location.href = "reciept.php?dist="   data   "{amp}amp;name="   name   "{amp}amp;mobile="   mobile   "{amp}amp;email="   email; } } }); } } {amp}lt;/script{amp}gt; 
Понравилась статья? Поделиться с друзьями:
JavaScript & TypeScript
Adblock
detector