Jump to content

Senthilkumar

Members
  • Posts

    171
  • Joined

  • Last visited

Everything posted by Senthilkumar

  1. Dear Mr.mac_gyver, I had changed the code litelbit as per your suggession. The output of the table is In this table the Deparment and Description will update fro the table "parts_service" based on the moth selection and the target values will display from the table "revenuetarget" The modified table code is <form method="POST" action="" onsubmit="return confirm('Are you sure you want to submit?');"> <div style="display: inline-block"> Select Month:<input type="month" name="month" class="month" id="month" onchange="myFunction()" placeholder="Select Month" required value="" style="width:auto;border:solid; border-color:black;font-family:Cambria;border-radius:5px;height:30px;margin-bottom:10px" /> </div> <div style="display: inline-block"> <input type="text" hidden name="dealerid" class="dealerid" id="dealerid" value="<?PHP echo $Emp_No ?>" style="width:100px" /> </div> <?PHP $col = ['Excavator', 'Grader', 'Wheel Loader', 'SLM', 'Revenue']; $target_txt = 'Target in lakh'; $actual_txt = 'Actual in lakh'; ?> <div class="tbl_fixed"> <table> <thead> <tr> <th style="width:5%;">S.no</th> <th style="width:10%;">Department</th> <th style="width:25%;">Description</th> <?php foreach($col as $c) { echo "<th style='width:6%;'>$c $target_txt</th>"; echo "<th style='width:6%;'>$c $actual_txt</th>"; } ?> </tr> </thead> <tbody> <?php // $qry=mysqli_query($conn,"SELECT * FROM users where Approver1_Name = '$Name' OR Approver2_Name = '$Name' "); $qry=mysqli_query($conn,"SELECT * FROM parts_service "); $n = 1; //while($row = $qry->fetch_assoc()){ //$Description = $row['Description']; //$Department = $row['Department']; // $Indicative_Margin = $row['Indicative_Margin']; $data = []; foreach ($qry as $row) { $data[$row['Description']][$row['Category_Name']] = $row; //} //print_r($data); ?> <tr> <td align='center'> <?php echo $n++ ?> </td> <td style="text-align:center"> <?php echo $row['Department']; ?> </td> <td hidden> <input type="text" name="Department[]" id="Department" value=" <?php echo $Department; ?> " style="width:100px" readonly /> </td> <td> <?php echo $row['Description']; ?> </td> <td hidden> <input type="text" name="Description[]" id='Description' value=" <?php echo $row; ?> " style="width:100px" readonly /> </td> <td style="text-align:center" hidden> <?php echo $Indicative_Margin; ?> % </td> <td style="width:100px"> <input type="number" class="form-control ExcavatorTarget " name="ExcavatorTarget[]" step="0.01" pattern="^\d+(?:\.\d{1,2})?$" id="ExcavatorTarget" value="" style="width:100%" readonly /> </td> <td style="width:100px"> <input type="number" class="form-control ExcavatorActual calc" name="ExcavatorActual[]" step="0.01" pattern="^\d+(?:\.\d{1,2})?$" id="ExcavatorActual" value="" style="width:100%" /> </td> <td style="width:100px"> <input type="number" class="form-control GraderTarget " name="GraderTarget[]" step="0.01" pattern="^\d+(?:\.\d{1,2})?$" id="GraderTarget" value="" style="width:100%" readonly /> </td> <td style="width:100px"> <input type="number" class="form-control GraderActual calc" name="GraderActual[]" step="0.01" pattern="^\d+(?:\.\d{1,2})?$" id="GraderActual" value="" style="width:100%" /> </td> <td style="width:100px"> <input type="number" class="form-control WheelLoaderTarget " name="WheelLoaderTarget[]" step="0.01" pattern="^\d+(?:\.\d{1,2})?$" id="WheelLoaderTarget" value="" style="width:100%" readonly /> </td> <td style="width:100px"> <input type="number" class="form-control WheelLoaderActual calc" name="WheelLoaderActual[]" step="0.01" pattern="^\d+(?:\.\d{1,2})?$" id="WheelLoaderActual" value="" style="width:100%" /> </td> <td style="width:100px"> <input type="number" class="form-control SLMTarget " name="SLMTarget[]" step="0.01" pattern="^\d+(?:\.\d{1,2})?$" id="SLMTarget" value="" style="width:100%" readonly /> </td> <td style="width:100px"> <input type="number" class="form-control SLMActual calc" name="SLMActual[]" step="0.01" pattern="^\d+(?:\.\d{1,2})?$" id="SLMActual" value="" style="width:100%" /> </td> <td style="width:100px"> <input type="number" class="form-control RevenueTarget " name="RevenueTarget[]" step="0.01" pattern="^\d+(?:\.\d{1,2})?$" id="RevenueTarget" value="" style="width:100%" readonly /> </td> <td style="width:100px"> <input type="number" class="form-control RevenueActual" name="RevenueActual[]" id="RevenueActual" step="0.01" pattern="^\d+(?:\.\d{1,2})?$" value="" style="width:100%" readonly /> </td> <td style="width:100px" hidden> <input type="number" name="Margin[]" class="form-control Margin" id="Margin" value="" style="width:100%" readonly autocomplete="off" /> </td> <td hidden align='center' style="width:10%"> <input type="checkbox" checked="checked" class="checkbox" name='lang[]' value="1" /> </td> </tr> <?php } ?> </tbody> </table> </div> <div style="text-align:center"> <input type="submit" name="addInvoice" class="addInvoice" id="addInvoice" value="Submit" style="width:100px;background: #0A2558;margin-top:10px; color:white;font-family:Cambria;border-radius:5px;height:30px;" /> </div> </form> Can you please suggest me for this
  2. Dear ginerjm, In my databse for Excavator--> Pure Parts --> Jan --> 12 and Excavator--> Rock Breaker --> Jan --> Null. Example: When i am selecting Jan month on my table i want it should display on S.no:1--> Pure Parts --> Excavator Target in Lakhs --> 12 and S.no:2--> Rock Breaker --> Excavator Target in Lakhs should disblay blank. When i am selecting March month on my table i want it should display on S.no:1--> Pure Parts --> Excavator Target in Lakhs --> 098 and S.no:2--> Rock Breaker --> Excavator Target in Lakhs --> 657. Like above all the values should display the category target as per the description in databse. I am not getting any idea, how to do this.
  3. Dear team, I am having two tables. One is to set the target values month wise and another one is to update the actual value agains the target month wise (display the target value). Once i set the target value, it is inserting the databse properly. My databse is My another page whis is using to update the actual values is looks like this In above picture, once i select the month, the target value should display automatically on desctiption inrow and category in column. My table code is <form method="POST" action="" onsubmit="return confirm('Are you sure you want to submit?');"> <div style="display: inline-block"> Select Month:<input type="month" name="month" class="month" id="month" onchange="myFunction()" placeholder="Select Month" required value="" style="width:auto;border:solid; border-color:black;font-family:Cambria;border-radius:5px;height:30px;margin-bottom:10px" /> </div> <div style="display: inline-block"> <input type="text" hidden name="dealerid" class="dealerid" id="dealerid" value="<?PHP echo $Emp_No ?>" style="width:100px" /> </div> <div class="tbl_fixed"> <table> <thead> <tr> <th style="width:5%;">S.no</th> <th style="width:10%;">Department</th> <th style="width:25%;">Description</th> <th hidden>Indicative Margin %</th> <th style="width:6%;">Excavator Target in lakh</th> <th style="width:6%;">Excavator Actual in lakh</th> <th style="width:6%;">Grader Target in lakh</th> <th style="width:6%;">Grader Actual in lakh</th> <th style="width:6%;">Wheel Loader Target in lakh</th> <th style="width:6%;">Wheel Loader Actual in lakh</th> <th style="width:6%;">SLM Target in lakh</th> <th style="width:6%;">SLM Actual in lakh</th> <th style="width:6%;">Revenue Target in lakh</th> <th style="width:6%;">Revenue Actual in lakh</th> </tr> </thead> <tbody> <?php $qry=mysqli_query($conn,"SELECT * FROM parts_service "); $n = 1; while($row = $qry->fetch_assoc()){ $Description = $row['Description']; $Department = $row['Department']; $Indicative_Margin = $row['Indicative_Margin']; ?> <tr> <td align='center'> <?php echo $n++ ?> </td> <td style="text-align:center"> <?php echo $Department; ?> </td> <td hidden> <input type="text" name="Department[]" id="Department" value=" <?php echo $Department; ?> " style="width:100px" readonly /> </td> <td> <?php echo $Description; ?> </td> <td hidden> <input type="text" name="Description[]" id='Description' value=" <?php echo $Description; ?> " style="width:100px" readonly /> </td> <td style="text-align:center" hidden> <?php echo $Indicative_Margin; ?> % </td> <td hidden> <input type="text" name="Indicative_Margin[]" class="Indicative_Margin" id="Indicative_Margin" value=" <?php echo $Indicative_Margin; ?> " style="width:100px" readonly /> </td> <td style="width:100px"> <input type="number" class="form-control ExcavatorTarget " name="ExcavatorTarget[]" step="0.01" pattern="^\d+(?:\.\d{1,2})?$" id="ExcavatorTarget" value="" style="width:100%" readonly /> </td> <td style="width:100px"> <input type="number" class="form-control ExcavatorActual calc" name="ExcavatorActual[]" step="0.01" pattern="^\d+(?:\.\d{1,2})?$" id="ExcavatorActual" value="" style="width:100%" /> </td> <td style="width:100px"> <input type="number" class="form-control GraderTarget " name="GraderTarget[]" step="0.01" pattern="^\d+(?:\.\d{1,2})?$" id="GraderTarget" value="" style="width:100%" readonly /> </td> <td style="width:100px"> <input type="number" class="form-control GraderActual calc" name="GraderActual[]" step="0.01" pattern="^\d+(?:\.\d{1,2})?$" id="GraderActual" value="" style="width:100%" /> </td> <td style="width:100px"> <input type="number" class="form-control WheelLoaderTarget " name="WheelLoaderTarget[]" step="0.01" pattern="^\d+(?:\.\d{1,2})?$" id="WheelLoaderTarget" value="" style="width:100%" readonly /> </td> <td style="width:100px"> <input type="number" class="form-control WheelLoaderActual calc" name="WheelLoaderActual[]" step="0.01" pattern="^\d+(?:\.\d{1,2})?$" id="WheelLoaderActual" value="" style="width:100%" /> </td> <td style="width:100px"> <input type="number" class="form-control SLMTarget " name="SLMTarget[]" step="0.01" pattern="^\d+(?:\.\d{1,2})?$" id="SLMTarget" value="" style="width:100%" readonly /> </td> <td style="width:100px"> <input type="number" class="form-control SLMActual calc" name="SLMActual[]" step="0.01" pattern="^\d+(?:\.\d{1,2})?$" id="SLMActual" value="" style="width:100%" /> </td> <td style="width:100px"> <input type="number" class="form-control RevenueTarget " name="RevenueTarget[]" step="0.01" pattern="^\d+(?:\.\d{1,2})?$" id="RevenueTarget" value="" style="width:100%" readonly /> </td> <td style="width:100px"> <input type="number" class="form-control RevenueActual" name="RevenueActual[]" id="RevenueActual" step="0.01" pattern="^\d+(?:\.\d{1,2})?$" value="" style="width:100%" readonly /> </td> <td style="width:100px" hidden> <input type="number" name="Margin[]" class="form-control Margin" id="Margin" value="" style="width:100%" readonly autocomplete="off" /> </td> <td hidden align='center' style="width:10%"> <input type="checkbox" checked="checked" class="checkbox" name='lang[]' value="1" /> </td> </tr> <?php } ?> </tbody> </table> </div> <div style="text-align:center"> <input type="submit" name="addInvoice" class="addInvoice" id="addInvoice" value="Submit" style="width:100px;background: #0A2558;margin-top:10px; color:white;font-family:Cambria;border-radius:5px;height:30px;" /> </div> </form> I dont know how to do this. Van any one help me how to do this
  4. Hello requinix I used the below code as per your instruction $previous_month = date('Y-m', mktime(0, 0, 0, date('n') - 1, 1)); But than also the same problem
  5. I changed the code as per your instruction. But when i am selecting the month from system browser it is displaying like below image When i am selecting month from mobile browser it is displaying like below image In above screen, when i am scroll down the month i am not able to select May month. Automatically it is going to Jun if i scroll it.
  6. Dear Team, I am having a input field which is using for select month. <?PHP $previous_month = date('Y-m', strtotime(date('Y-m') . " -1 month")); $current_month = date('Y-m'); ?> <input type="month" name="Month" id="Month" class="form-control" onchange="viewData()" min="<?php echo $previous_month; ?>" max="<?php echo $current_month; ?>" required style="width:auto;font-family:Cambria;border-radius:5px;height:30px" /> This input will display previous month and cutrrent month only. When i am checking the output of this input is working properly on my laptop browser, i can able to select both the month. But when ia m checking the output on my mobile browser, i can select only current month. ie.. max value. If i scroll down the month list, again it is going to max value only. If suppose the minimum value is -2 (ie.. 2month ) then i can able to select on my mobile browser. But when i am ggiven one month i am not able to select previous month. Can any one suggest me where is the mistake and how to rectify this issue.
  7. Dear mac_gyver, Thanks for your suggession. I had changed the input name for the row total. So now it is updating properly as per my requirement. Thaks for your support.
  8. Dear mac_gyver, Thanks. I have modified the code with reference of above code. Now each month's column total is working properly. But while inserting the values to database the column total value is not inserting as seperate row . it is inserting on the next grade first row. Can you please help me.
  9. Dear Mac_Gyver, Thanks for your reply and this is working exactly as per my requirement. But in this i am facing some issues. I tried for each month's column total with the following code. But only December month is passing on the script. // Column total month wise $(this).closest('tbody').find('.<?=$m?>').each(function () { y = parseInt($(this).val()); col_total += isNaN(y) ? 0 : y; }); $(this).closest('tbody').find('.col_Total<?=$m?>').val(col_total); So i have tried to calculate month wise like bellow code and it is updating the month's column toltal. // Column total Jan $(this).closest('tbody').find('.Jan').each(function () { y = parseInt($(this).val()); col_total += isNaN(y) ? 0 : y; }); $(this).closest('tbody').find('.col_TotalJan').val(col_total); If i use the above code, I have to create for all the 12 month separatly. My final script is <script> $(document).ready(function () { $(".calc").on('input', function () { var row_total = 0; var cat_total = 0; var col_total = 0; var col_total1 = 0,col_total2 = 0,col_total3 = 0,col_total4 = 0,col_total5 = 0,col_total6 = 0,col_total7 = 0,col_total8 = 0,col_total9 = 0,col_total10 = 0,col_total11 = 0; var x; var ms; var y, a, b, c, d, e, f,g,h,i,j,k; // current row total $(this).closest('tr').find('.calc').each(function () { x = parseInt($(this).val()); row_total += isNaN(x) ? 0 : x; }); $(this).closest('tr').find('.Total').val(row_total); // category total $(this).closest('tbody').find('.Total').each(function () { x = parseInt($(this).val()); cat_total += isNaN(x) ? 0 : x; }); $(this).closest('tbody').find('.cat_Total').val(cat_total); // Column total Jan $(this).closest('tbody').find('.Jan').each(function () { y = parseInt($(this).val()); col_total += isNaN(y) ? 0 : y; }); $(this).closest('tbody').find('.col_TotalJan').val(col_total); // Column total Feb $(this).closest('tbody').find('.Feb').each(function () { a = parseInt($(this).val()); col_total1 += isNaN(a) ? 0 : a; }); $(this).closest('tbody').find('.col_TotalFeb').val(col_total1); // Column total Mar $(this).closest('tbody').find('.Mar').each(function () { b = parseInt($(this).val()); col_total2 += isNaN(b) ? 0 : b; }); $(this).closest('tbody').find('.col_TotalMar').val(col_total2); // Column total Apr $(this).closest('tbody').find('.Apr').each(function () { c = parseInt($(this).val()); col_total3 += isNaN(c) ? 0 : c; }); $(this).closest('tbody').find('.col_TotalApr').val(col_total3); // Column total May $(this).closest('tbody').find('.May').each(function () { d = parseInt($(this).val()); col_total4 += isNaN(d) ? 0 : d; }); $(this).closest('tbody').find('.col_TotalMay').val(col_total4); // Column total Jun $(this).closest('tbody').find('.Jun').each(function () { e = parseInt($(this).val()); col_total5 += isNaN(e) ? 0 : e; }); $(this).closest('tbody').find('.col_TotalJun').val(col_total5); // Column total Jul $(this).closest('tbody').find('.Jul').each(function () { f = parseInt($(this).val()); col_total6 += isNaN(f) ? 0 : f; }); $(this).closest('tbody').find('.col_TotalJul').val(col_total6); // Column total Aug $(this).closest('tbody').find('.Aug').each(function () { g = parseInt($(this).val()); col_total7 += isNaN(g) ? 0 : g; }); $(this).closest('tbody').find('.col_TotalAug').val(col_total7); // Column total Sep $(this).closest('tbody').find('.Sep').each(function () { h = parseInt($(this).val()); col_total8 += isNaN(h) ? 0 : h; }); $(this).closest('tbody').find('.col_TotalSep').val(col_total8); // Column total Oct $(this).closest('tbody').find('.Oct').each(function () { i = parseInt($(this).val()); col_total9 += isNaN(i) ? 0 : i; }); $(this).closest('tbody').find('.col_TotalOct').val(col_total9); // Column total Nov $(this).closest('tbody').find('.Nov').each(function () { j = parseInt($(this).val()); col_total10 += isNaN(j) ? 0 : j; }); $(this).closest('tbody').find('.col_TotalNov').val(col_total10); // Column total Dec $(this).closest('tbody').find('.Dec').each(function () { k = parseInt($(this).val()); col_total11 += isNaN(k) ? 0 : k; }); $(this).closest('tbody').find('.col_TotalDec').val(col_total11); // ms calc = each row total/cat_Total * 100 $(this).closest('tbody').find('.Total').each(function (index) { x = parseInt($(this).val()); ms = (isNaN(x) ? 0 : x)/cat_total*100; $(this).closest('tbody').find('.MS').eq(index).val(ms.toFixed(2)); }); }); }); </script> Next problem i am facing is, When i am insert the values to database, Once the first category is completed, the month wise total value is updating on next category because of we merged on first three columns. My inserting code is <?php if(isset($_POST['addInvoice'])){ $Dealer_ID = $_POST['Dealer_Name']; $dealname = mysqli_query($conn, "SELECT * from users WHERE Emp_No = '$Dealer_ID'"); $dealerrow = $dealname->fetch_assoc(); $Dealername = $dealerrow['Name']; $Current_Year = date("Y"); foreach ($_POST['lang'] as $ID => $VAL) { $Category = $_POST['Category_Name'][$ID]; $Model= $_POST['Model_Name'][$ID]; $Jan = $_POST['Jan'][$ID]; $Feb = $_POST['Feb'][$ID]; $Mar = $_POST['Mar'][$ID]; $Apr = $_POST['Apr'][$ID]; $May = $_POST['May'][$ID]; $Jun = $_POST['Jun'][$ID]; $Jul = $_POST['Jul'][$ID]; $Aug = $_POST['Aug'][$ID]; $Sep = $_POST['Sep'][$ID]; $Oct = $_POST['Oct'][$ID]; $Nov = $_POST['Nov'][$ID]; $December= $_POST['Dec'][$ID]; $Total = $_POST['Total'][$ID]; $MS = $_POST['MS'][$ID]; //$query = "UPDATE users SET Branch ='$Branch', Posting_Location ='$Posted_Location', Department='$Department', Divison='$Division', Emp_No='$Emp_No', Name='$Name', Designation='$Designation', User_Type='$User_Type', Functional_Role='$Functional_Role', Employed='$Employed', Mobile='$Mobile', Email='$Email', DOJ='$DOJ', Qualifications='$Qualifications', DOB='$DOB', Approver1_ID='$Approver1_ID', Approver1_Name='$Approver1_Name', Approver2_ID='$Approver2_ID', Approver2_Name='$Approver2_Name' , Approver='$Approver', Gender='$Gender', Blood='$Blood' WHERE id = '$ida'"; $query = "INSERT INTO lastyeardata (Dealer_ID, Dealername, Category, Model, Year, Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, December, Total, MS) VALUES ('$Dealer_ID','$Dealername', '$Category','$Model','$Current_Year','$Jan', '$Feb','$Mar', '$Apr', '$May', '$Jun','$Jul', '$Aug', '$Sep','$Oct', '$Nov', '$December','$Total','$MS')"; $result = mysqli_query($conn, $query); if($result) { // echo "<script type='text/javascript'> document.location = 'Users.php'; </script>"; echo '<script type="text/javascript">Swal.fire({ text: "Last Year Data Details added Successfully", icon: "success", showCancelButton: false, confirmButtonColor: "#3085d6", confirmButtonText: "OK" }).then((result) => { if (result.isConfirmed) { window.location.href = "Last_Year_Data.php" } })</script>'; } else { //echo '<script type="text/javascript"> alert("Details are Not Updated.")</script>'; echo '<script type="text/javascript">Swal.fire({ text: "Details are Not Updated. Please check the details entered.", icon: "error", showCancelButton: false, confirmButtonColor: "#3085d6", confirmButtonText: "OK" }).then((result) => { if (result.isConfirmed) { window.history.back() } })</script>'; } } } ?> <form method="POST" action=""> <div style="display: inline-block"> <div class="col-md-12"><label class="control-label">Dealer Name</label> <select name="Dealer_Name" required class="form-control dropdown-toggle Dealer_Name" > <option value="">Select Dealer Name </option> <?php $qry = mysqli_query($conn,"SELECT * FROM users WHERE User_Type ='Dealer' AND status = '1';"); while($row = $qry->fetch_assoc()) { echo '<option value="' . $row['Emp_No'] . '">' . $row['Name'] . '</option>'; } ?> </select> </div> </div> <div id="wrap" class="datalist-wrapper" style="margin-top:-15px"> <div class="loading-overlay"> <div class="overlay-content">Loading...</div> </div> <div class="" id="dataContainer"> <?php // generate month labels foreach(range(1,12) as $m) { $mon[] = ucfirst(date('M',strtotime("2023-$m-01"))); } ?> <table style="margin-top:40px; height:15px" id="example" cellpadding="0" cellspacing="0" border="0" class="datatable table-sm table-hover table-striped table-bordered"> <thead> <tr> <?php $Year = date("y"); $previousYear = $Year - 1; ?> <th style="text-align:center; font-weight:bold;width:2%">S.No</th> <th style="text-align:center; font-weight:bold;width:8%">Category</th> <th style="text-align:center; font-weight:bold;width:8%">Model</th> <?php foreach($mon as $m) {?> <th style="text-align:center; font-weight:bold;width:4.5%"><?=$m.$previousYear?></th> <?php } ?> <th style="text-align:center; font-weight:bold;width:5%">Total</th> <th style="text-align:center; font-weight:bold;width:7%">MS %</th> </tr> </thead> <?php $qry=mysqli_query($conn,"SELECT * FROM model WHERE Brand_ID = '1' order by Category_Name ASC"); $n = 1; // remember last category, to detect when it changes $last_cat = ''; while($row = $qry->fetch_assoc()) { $Category_Name = $row['Category_Name']; $Model_Name = $row['Model_Name']; // detect if the category changed if($last_cat !== $row['Category_Name']) { // test if not the first output if($last_cat !== '') { // close the previous section - output a total row ?> <tr> <td colspan="3" style="text-align:center"> <?PHP echo $last_cat; ?> TOTAL</td> <?php foreach($mon as $m) {?> <td><input type="number" class="form-control col_Total<?=$m?>" name="<?=$m?>[]" style="width:100%" readonly></td> <?php } ?> <td><input type="number" name="cat_Total[]" class="form-control cat_Total" style="width:100%" readonly></td> <td>&nbsp;</td> </tr> <?php } // remember the new category $last_cat = $row['Category_Name']; // start a new section ?> <tbody> <?php } ?> <tr> <td align='center'><?=$n++?></td> <td style="text-align:center"><?=$row['Category_Name']?></td> <td hidden> <input type="text" name="Category_Name[]" id="Category_Name" value=" <?php echo $Category_Name; ?> " style="width:100px" readonly /> </td> <td style="text-align:center"><?=$row['Model_Name']?></td> <td hidden> <input type="text" name="Model_Name[]" id="Model_Name" value=" <?php echo $Model_Name; ?> " style="width:100px" readonly /> </td> <?php foreach($mon as $m) {?> <td><input type="number" class="form-control calc <?=$m?>" name="<?=$m?>[]" style="width:100%" ></td> <?php } ?> <td><input type="number" name="Total[]" class="form-control Total" style="width:100%" readonly></td> <td><input type="number" name="MS[]" class="form-control MS" style="width:100%" readonly></td> <td hidden align='center'> <input type="checkbox" checked="checked" class="checkbox" name='lang[]' value="1" /> </td> </tr> <?php } // end of data loop // if there was any output, close out the last section if($last_cat !== '') { // close the previous section - output a total row ?> <tr> <td hidden> <td colspan="3" style="text-align:center"><?PHP echo $last_cat; ?> TOTAL</td> <?php foreach($mon as $m) {?> <td><input type="number" class="form-control col_Total<?=$m?>" name="<?=$m?>[]" style="width:100%" readonly></td> <?php } ?> <td><input type="number" name="cat_Total[]" class="form-control cat_Total" style="width:100%" readonly></td> <td>&nbsp;</td> </tr> </tbody> <?php } ?> </table> </div> </div> <div style="text-align:center"> <input type="submit" name="addInvoice" class="addInvoice" id="addInvoice" value="Submit" style="width:100px;background: #0A2558;margin-top:10px; color:white;font-family:Cambria;border-radius:5px;height:30px;" /> </div> </form> Can you please help me to insert the values on database along with column total.
  10. Dear Team, I am creating a table with dynamic rows based on the data available on my databse. In that table having input fields on oall the columns. I want to sum of entire row and update on total colum while typing the input. Then sum entire column of total automatically. Then i have to get % of rowtotal & columntotal. In this image the Total column will update the sum of entire row. Out put is 4. Then in colum Total 1260 is the sum of category Excavator. So my for row SM% is (4/1260)*100. Then in 2nd row SM% is (59/1260)*100. For all the category Excavator the SM% should update with divided by 1260. Also for Wheel loader it should update (108/108)*100 and for Grader it should update (21/21)*100. I want the calculation should happen like this. My table code is <table style="margin-top:40px; height:15px" id="example" cellpadding="0" cellspacing="0" border="0" class="datatable table-sm table-hover table-striped table-bordered"> <thead> <tr> <?PHP $Year = date("y"); $previousYear = $Year - 1; ?> <th style="text-align:center; font-weight:bold;width:2%">S.No</th> <th style="text-align:center; font-weight:bold; width:10%">Category</th> <th style="text-align:center; font-weight:bold; width:10%">Model</th> <th style="text-align:center; font-weight:bold;width:4.5%">Jan<?PHP echo $previousYear; ?></th> <th style="text-align:center; font-weight:bold;width:4.5%">Feb<?PHP echo $previousYear; ?></th> <th style="text-align:center; font-weight:bold;width:4.5%">Mar<?PHP echo $previousYear; ?></th> <th style="text-align:center; font-weight:bold;width:4.875%"hidden>Q1</th> <th style="text-align:center; font-weight:bold;width:4.5%">Apr<?PHP echo $previousYear; ?></th> <th style="text-align:center; font-weight:bold;width:4.5%">May<?PHP echo $previousYear; ?></th> <th style="text-align:center; font-weight:bold;width:4.5%">Jun<?PHP echo $previousYear; ?></th> <th style="text-align:center; font-weight:bold;width:4.875%"hidden>Q2</th> <th style="text-align:center; font-weight:bold;width:4.5%">Jul<?PHP echo $previousYear; ?></th> <th style="text-align:center; font-weight:bold;width:4.5%">Aug<?PHP echo $previousYear; ?></th> <th style="text-align:center; font-weight:bold;width:4.5%">Sep<?PHP echo $previousYear; ?></th> <th style="text-align:center; font-weight:bold;width:4.875%"hidden>Q3</th> <th style="text-align:center; font-weight:bold;width:4.5%">Oct<?PHP echo $previousYear; ?></th> <th style="text-align:center; font-weight:bold;width:4.5%">Nov<?PHP echo $previousYear; ?></th> <th style="text-align:center; font-weight:bold;width:4.5%">Dec<?PHP echo $previousYear; ?></th> <th style="text-align:center; font-weight:bold;width:4.5%"hidden>Q4</th> <th style="text-align:center; font-weight:bold;width:4.875%">Total</th> <th style="text-align:center; font-weight:bold;width:4.875%">MS %</th> </tr> </thead> <tbody> <?php // $qry=mysqli_query($conn,"SELECT * FROM users where Approver1_Name = '$Name' OR Approver2_Name = '$Name' "); $qry=mysqli_query($conn,"SELECT * FROM model WHERE Brand_ID = '1' order by Category_Name ASC"); $n = 1; while($row = $qry->fetch_assoc()){ $Category_Name = $row['Category_Name']; $Model_Name = $row['Model_Name']; ?> <tr> <td align='center'> <?php echo $n++ ?> </td> <td style="text-align:center"> <?php echo $Category_Name; ?> </td> <td hidden> <input type="text" name="Category_Name[]" id="Category_Name" value=" <?php echo $Category_Name; ?> " style="width:100px" readonly /> </td> <td style="text-align:center"> <?php echo $Model_Name; ?> </td> <td hidden> <input type="text" name="Model_Name[]" id="Model_Name" value=" <?php echo $Model_Name; ?> " style="width:100px" readonly /> </td> <td > <input type="number" class="form-control Jan" name="Jan[]" id="Jan" value="" style="width:100%" required/> </td> <td > <input type="number" class="form-control Feb" name="Feb[]" id="Feb" value="" style="width:100%" required/> </td> <td > <input type="number" class="form-control Mar" name="Mar[]" id="Mar" value="" style="width:100%" required/> </td> <td hidden> <input type="number" name="Q1[]" id="Q1" class="form-control Q1" value="Q1" style="width:100%" readonly /> </td> <td> <input type="number" class="form-control Apr" name="Apr[]" id="Apr" value="" style="width:100%" required/> </td> <td> <input type="number" class="form-control May" name="May[]" id="May" value="" style="width:100%" required/> </td> <td> <input type="number" class="form-control Jun" name="Jun[]" id="Jun" value="" style="width:100%" required/> </td> <td hidden> <input type="number" name="Q2[]" id="Q2" class="form-control Q2" value="" style="width:100%" readonly/> </td> <td> <input type="number" class="form-control Jul" name="Jul[]" id="Jul" value="" style="width:100%" required/> </td> <td> <input type="number" class="form-control Aug" name="Aug[]" id="Aug" value="" style="width:100%" required/> </td> <td> <input type="number" class="form-control Sep" name="Sep[]" id="Sep" value="" style="width:100%" required/> </td> <td hidden> <input type="number" name="Q3[]" id="Q3" class="form-control Q3" value="" style="width:100%" readonly/> </td> <td > <input type="number" class="form-control Oct" name="Oct[]" id="Oct" value="" style="width:100%" required/> </td> <td> <input type="number" class="form-control Nov" name="Nov[]" id="Nov" value="" style="width:100%" required/> </td> <td> <input type="number" class="form-control Dec" name="Dec[]" id="Dec" value="" style="width:100%" required/> </td> <td hidden> <input type="number" name="Q4[]" id="Q4" class="form-control Q4" value="" style="width:100%" readonly/> </td> <td> <input type="number" name="Total[]" id="Total" class="form-control Total" value="" style="width:100%" readonly/> </td> <td> <input type="number" name="MS%[]" id="MS%" class="form-control MS%" value="" style="width:100%" readonly/> </td> <td hidden align='center'> <input type="checkbox" checked="checked" class="checkbox" name='lang[]' value="1" /> </td> </tr> <?php } ?> </tbody> </table> I am using the following script for calculating Row total and column total <script> $(document).ready(function () { $(".Jan, .Feb, .Mar, .Apr, .May, .Jun, .Jul, .Aug, .Sep, .Oct, .Nov, .Dec ").keyup(function () { $("input[name='Dec[]']").each(function (index) { var Jan = $("input[name='Jan[]']").eq(index).val(); var Feb = $("input[name='Feb[]']").eq(index).val(); var Mar = $("input[name='Mar[]']").eq(index).val(); var Apr = $("input[name='Apr[]']").eq(index).val(); var May = $("input[name='May[]']").eq(index).val(); var Jun = $("input[name='Jun[]']").eq(index).val(); var Jul = $("input[name='Jul[]']").eq(index).val(); var Aug = $("input[name='Aug[]']").eq(index).val(); var Sep = $("input[name='Sep[]']").eq(index).val(); var Oct = $("input[name='Oct[]']").eq(index).val(); var Nov = $("input[name='Nov[]']").eq(index).val(); var Dec = $("input[name='Dec[]']").eq(index).val(); var Row_Total =parseInt(Jan) + parseInt(Feb) + parseInt(Mar) + parseInt(Apr) + parseInt(May) + parseInt(Jun) + parseInt(Jul) + parseInt(Aug) + parseInt(Sep) + parseInt(Oct) + parseInt(Nov) + parseInt(Dec); if (!isNaN(Row_Total)) { $("input[name='Total[]']").eq(index).val(Row_Total); } }); var Column_Total = 0.0; $.each($(".Total"), function (key, input) { if (input.value && !isNaN(input.value)) { Column_Total += parseFloat(input.value); } }) }); }); </script> I was struckup with this position. I dont know how to update MS% row wise. Can any one help me to complete this process.
  11. Dear Mac-Gayer, Thanks for your reply. I created span <span id=file1<?php echo $row['Ass_ID']; ?>><a></a></span> And i append my Directory & Document on this span. $("#file1" + Ass_ID).append('<a target="_blank" href="' + Directory + '/' + Document + '">' + Document + '</a>'); Now it is working properly. Thank you for supporting me.
  12. Dear Mac I get the directory and document values and created the variable on my script. $query = "SELECT * FROM mykra where Month= '$Month' AND Engg_No = '$Employeeid' AND Status = '0'"; $result = mysqli_query($conn, $query); while ($row = mysqli_fetch_array($result)) { $Ass_ID = $row['Row_id']; $Ass_Description = $row['Point_Description']; $Ass_Marks = $row['Point_Marks']; $target = $row['Marks_Target']; $actual = $row['Marks_Actual']; $date = $row['DOS']; $remarks = $row['Marks_Description']; $Document= $row['Document']; $Directory = $row['Directory']; $return_arr[] = array( "Ass_ID" => $Ass_ID, "Ass_Description" => $Ass_Description, "Ass_Marks" => $Ass_Marks, "target" => $target, "actual" => $actual, "date" => $date, "Document" => $Document, "Directory" => $Directory, "remarks" => $remarks ); } echo json_encode($return_arr); for (var i = 0; i < len; i++) { var Ass_ID = response[i].Ass_ID; var Ass_Description = response[i].Ass_Description; var Ass_Marks = response[i].Ass_Marks; var target = response[i].target; var actual = response[i].actual; var date = response[i].date; var remarks = response[i].remarks; var Document = response[i].Document; var Directory = response[i].Directory; document.getElementById('Ass_Description'+Ass_ID).value = Ass_Description; document.getElementById('Ass_Marks'+Ass_ID).value = Ass_Marks; document.getElementById('target'+Ass_ID).value = target; document.getElementById('actual'+Ass_ID).value = actual; document.getElementById('date'+Ass_ID).value = date; document.getElementById('remarks' + Ass_ID).value = remarks; document.getElementById('file' + Ass_ID).value = Document; } but i don't know how to append this on my href. Can yo please help me
  13. Dear AKADRUMMIN, Thanks for your reply. All the values are updaing properly on the same row. But the file is not showing. <td align='center' style="width:19%"> <input type="file" name="file[]" id="file" accept=".jpg, .jpeg, .png, .pdf, .xlsx" value="" class="tbl-input-cus1 " /> <a href=" http://localhost:63640/<?php echo $Directory; ?>/<?php echo $Document; ?>" target="_blank"> <?php echo $Document; ?> </a> <input type="hidden" class="ids" name='lang[]' value="<?php echo $row['Ass_ID']; ?>" /> </td> The file is updating. But not able to display in href. Pls suggest
  14. Hi The bellow is my table. While page is loading, initially the Actual, Dote of Submission, Remarks and documents will be display empty. If the data is exist on database and meets my condition ( $query = "SELECT* FROM mykra where Month= '$Month' AND Engg_No = '$Employeeid' AND Status = '0'";) it should display the Actual, Dote of Submission, Remarks and documents values on the same table. My table is <div class="body" style="margin-top:2%"> <form method="post" action="" enctype="multipart/form-data"> <div class="date"> Month of the Submission: <input type="month" name="Month" id="Month" onchange="viewData()" min="<?php echo $previous_month; ?>" max="<?php echo $current_month; ?>" required style="width:auto;border:solid; border-color:black;font-family:Cambria;border-radius:5px;height:30px" /> <input type="text" name="employeeno" id="employeeno" hidden value="<?php echo $Emp_No; ?>" /> </div> <div class="tbl-header"> <table cellpadding="0" cellspacing="0" border="0"> <thead> <tr> <th align='center' style="width:4%">S.No</th> <th style="width:25%">Description</th> <th style="width:25%">Ratings</th> <th style="width:8%">Target</th> <th style="width:8%">Actual</th> <th style="width:17%">Date of Submission</th> <th style="width:17%">Remarks</th> <th style="width:19%">Document</th> </tr> </thead> </table> </div> <div class="tbl-content"> <table cellpadding="0" cellspacing="0" border="0"> <tbody> <?php $n = 1; while($row = mysqli_fetch_assoc($result)){ $ID= $row['Ass_ID']; $Name = $row['User_Name']; $Ass_Description = $row['Ass_Description']; $Ass_Marks = $row['Ass_Marks']; $Ass_Assigned = $row['Ass_Assigned']; $Emp_No = $row['User_EMp_No']; $mandatory = $row['Mandatory']; if($mandatory == 'Yes'){ $man = '*'; }else { $man = ''; } $query3=mysqli_query($conn,"SELECT * FROM mykra WHERE Engg_No = '$Emp_No' AND Month = '$Mon' AND Row_id = '$ID' AND Status = 0 "); $row1 = mysqli_fetch_assoc($query3); $Marks_Target = $row1['Marks_Target']; $Marks_Actual = $row1['Marks_Actual']; $Marks_Description = $row1['Marks_Description']; $DOS = $row1['DOS']; $Document = $row1['Document']; $Directory = $row1['Directory']; if($Marks_Target == ''){ $target = '1'; }else{ $target = $Marks_Target; } ?> <tr> <td align='center' style="width:4%"> <?php echo $n++; ?> </td> <td style="width:25%"> <?php echo $Ass_Description; ?> </td> <td hidden align='center' style="width:5%"> <input type="text" name="description[]" id="Ass_Description" value="<?php echo $Ass_Description; ?>" class="tbl-input-cus" tabindex="1" /> </td> <td style="width:25%"> <?php echo $Ass_Marks; ?> </td> <td hidden align='center' style="width:5%"> <input type="text" name="rating[]" id="Ass_Marks" value="<?php echo $Ass_Marks; ?>" class="tbl-input-cus" /> </td> <td align='center' style="width:8%"> <input type="text" name="target[]" id="target" class="tbl-input-cus" value="1" /> </td> <td align='center' style="width:8%"> <input type="number" name="actual[]" id="actual" min="-1" max="1" step="0.01" value="" class="tbl-input-cus" /> </td> <td align='center' style="width:17%"> <input type="date" name="date[]" id="date" value="" class="tbl-input-cus" /> </td> <td align='center' style="width:17%"> <input type="text" name="remarks[]" id="remarks" value="" class="tbl-input-cus1" /> </td> <td align='center' style="width:19%"> <input type="file" name="file[]" id="file" accept=".jpg, .jpeg, .png, .pdf, .xlsx" value="" class="tbl-input-cus1 " /> <a href=" http://localhost:63640/<?php echo $Directory; ?>/<?php echo $Document; ?>" target="_blank"> <?php echo $Document; ?> </a> </td> <td hidden align='center' style="width:10%"> <input type="checkbox" checked="checked" class="checkbox" name='lang[]' value="<?php echo $ID; ?>" /> </td> </tr> <?php } ?> </tbody> </table> </div> <p style="text-align:center; color:red"> <b>Note:</b> Before clicking Final Submit, first click <b>Save</b> then click <b>Preview</b> and finally <b>Final Submit</b>. </p> <div class="row"> <div class="padding"> <button type="submit" name="save" value="Submit" class="btn">Save</button> </div> <div class="padding"> <!--<a class="btn" popup-open="popup-1" name="preview" href="javascript:void(0)" >Preview</a>--> <!-- <button type="submit" name="preview" value="Submit" class="btn">Preview</button>--> <!-- <a class="link" onclick="document.getElementById('id02').style.display='block'">View</a>--> <a class="btn" href="#?edit=<?php echo $id ; ?>,<?php echo $min ; ?>" onclick="getProfileData('<?=$id?>', '<?=$min?>')">Preview</a> </div> <div class="padding"> <button type="submit" name="submit" value="Submit" class="btn"> Final Submit</button> </div> </div> </form> </div> My month change Jquery is <script> function viewData() { var month = document.getElementById("Month").value; var employeeid = document.getElementById("employeeno").value; $.ajax({ type: 'get', dataType: 'JSON', url: 'Mykra_view.php', data: 'Month=' + month + '&employeeno=' + employeeid, success: function (response) { var len = response.length; for (var i = 0; i < len; i++) { var Ass_Description = response[i].Ass_Description; var Ass_Marks = response[i].Ass_Marks; var target = response[i].target; var actual = response[i].actual; var date = response[i].date; var remarks = response[i].remarks; var file = response[i].file; document.getElementById("Ass_Description").value = Ass_Description; document.getElementById("Ass_Marks").value = Ass_Marks; document.getElementById("target").value = target; document.getElementById("actual").value = actual; document.getElementById("date").value = date; document.getElementById("remarks").value = remarks; document.getElementById("file").value = file; } } }); }; </script> my Mykraview.php is <?php include("../connection.php"); if(isset($_GET['Month'])){ $Month = $_GET['Month']; $Employeeid = $_GET['employeeno']; $query = "SELECT* FROM mykra where Month= '$Month' AND Engg_No = '$Employeeid' AND Status = '0'"; $result = mysqli_query($conn, $query); while ($row = mysqli_fetch_array($result)) { $Ass_Description = $row['Point_Description']; $Ass_Marks = $row['Point_Marks']; $target = $row['Marks_Target']; $actual = $row['Marks_Actual']; $date = $row['DOS']; $remarks = $row['Marks_Description']; $return_arr[] = array( "Ass_Description" => $Ass_Description, "Ass_Marks" => $Ass_Marks, "target" => $target, "actual" => $actual, "date" => $date, "remarks" => $remarks ); } echo json_encode($return_arr); } ?> With these above code when i am selecting the month, if data is exist it will displaying the values on first row only. Remaining rows are not displaying. Plesae help me. My databse is looks
  15. Dear Team, I have a table that I use to store the values and then submit them in final form month by month. Depending on the month selected, I want to retrieve the previously saved data and display the results in a table. It should show blank values if the final submission for that particular month has been made. The table should initially be empty while the page is loading. My table is <form method="post" action="" enctype="multipart/form-data"> <div class="date"> Month of the Submission: <input type="month" name="Month" id="Month" onchange="myFunction1()" min="<?php echo $previous_month; ?>" max="<?php echo $current_month; ?>" required style="width:auto;border:solid; border-color:black;font-family:Cambria;border-radius:5px;height:30px" /> <input type="text" name="employeeno" id="employeeno" hidden value="<?php echo $Emp_No; ?>" /> </div> <div class="tbl-header"> <table cellpadding="0" cellspacing="0" border="0"> <thead> <tr> <th align='center' style="width:4%">S.No</th> <th style="width:25%">Description</th> <th style="width:25%">Ratings</th> <th style="width:8%">Target</th> <th style="width:8%">Actual</th> <th style="width:17%">Date of Submission</th> <th style="width:17%">Remarks</th> <th style="width:19%">Document</th> </tr> </thead> </table> </div> <div class="tbl-content"> <table cellpadding="0" cellspacing="0" border="0"> <tbody> <?php $n = 1; while($row = mysqli_fetch_assoc($result)){ $ID= $row['Ass_ID']; $Name = $row['User_Name']; $Ass_Description = $row['Ass_Description']; $Ass_Marks = $row['Ass_Marks']; $Ass_Assigned = $row['Ass_Assigned']; $Emp_No = $row['User_EMp_No']; $mandatory = $row['Mandatory']; if($mandatory == 'Yes'){ $man = '*'; }else { $man = ''; } ?> <tr> <td align='center' style="width:4%"> <?php echo $n++; ?> </td> <td style="width:25%"> <?php echo $Ass_Description; ?> </td> <td hidden align='center' style="width:5%"> <input type="text" name="description[]" id="Ass_Description" value="<?php echo $Ass_Description; ?>" class="tbl-input-cus" tabindex="1" /> </td> <td style="width:25%"> <?php echo $Ass_Marks; ?> </td> <td hidden align='center' style="width:5%"> <input type="text" name="rating[]" id="Ass_Marks" value="<?php echo $Ass_Marks; ?>" class="tbl-input-cus" /> </td> <td align='center' style="width:8%"> <input type="text" name="target[]" id="target" class="tbl-input-cus" value="1" /> </td> <td align='center' style="width:8%"> <input type="number" name="actual[]" id="actual" min="-1" max="1" step="0.01" value="" class="tbl-input-cus" /> </td> <td align='center' style="width:17%"> <input type="date" name="date[]" id="date" value="" class="tbl-input-cus" /> </td> <td align='center' style="width:17%"> <input type="text" name="remarks[]" id="remarks" value="" class="tbl-input-cus1" /> </td> <td align='center' style="width:19%"> <input type="file" name="file[]" id="file" accept=".jpg, .jpeg, .png, .pdf, .xlsx" value="" class="tbl-input-cus1 " /> <a href=" http://localhost:63640/<?php echo $Directory; ?>/<?php echo $Document; ?>" target="_blank"> <?php echo $Document; ?> </a> </td> <td hidden align='center' style="width:10%"> <input type="checkbox" checked="checked" class="checkbox" name='lang[]' value="<?php echo $ID; ?>" /> </td> </tr> <?php } ?> </tbody> </table> </div> <div class="row"> <div class="padding"> <button type="submit" name="save" value="Submit" class="btn">Save</button> </div>> <div class="padding"> <button type="submit" name="submit" value="Submit" class="btn"> Final Submit</button> </div> </div> </form> My script for retrive data from databse is <script> function myFunction1() { var month = document.getElementById("Month").value; var employeeid = document.getElementById("employeeno").value; $.ajax({ type: 'get', dataType: 'JSON', url: 'Mykra_view.php', data: 'Month=' + month + '&employeeno=' + employeeid, success: function (response) { var len = response.length; for (var i = 0; i < len; i++) { var Ass_Description = response[i].Ass_Description; var Ass_Marks = response[i].Ass_Marks; var target = response[i].target; var actual = response[i].actual; var date = response[i].date; var remarks = response[i].remarks; var file = response[i].file; $("#Ass_Description").html(Ass_Description); $("#Ass_Marks").html(Ass_Marks); $("#target").html(target); $("#actual").html(actual); $("#date").html(date); $("#remarks").html(remarks); $("#file").html(file); } } }); } </script> Mykra_view.php is <?php include("../connection.php"); if(isset($_GET['Month'])){ $Month = $_GET['Month']; $Employeeid = $_GET['employeeno']; $query = "SELECT* FROM mykra where Month= '$Month' AND Engg_No = '$Employeeid' AND Status = '0'"; $result = mysqli_query($conn, $query); while ($row = mysqli_fetch_array($result)) { $Ass_Description = $row['Point_Description']; $Ass_Marks = $row['Point_Marks']; $target = $row['Marks_Target']; $actual = $row['Marks_Actual']; $date = $row['DOS']; $remarks = $row['Marks_Description']; $return_arr[] = array( "Ass_Description" => $Ass_Description, "Ass_Marks" => $Ass_Marks, "target" => $target, "actual" => $actual, "date" => $date, "remarks" => $remarks ); } echo json_encode($return_arr); } with above code, when i am selecting month, Mykra_view.php is running and fetch the data from database. But it is not displaying table. Can any one please help me to clear this problem.
  16. Dear Gyver, I changed the script as per your suggession. Now all are working properly. My final code is <script> $(document).on('change', '.Brand', function(){ var BrandID = $(this).val(); var parent = $(this).closest('.parent-container'); if(BrandID){ $.ajax({ type:'POST', url:'ajaxData.php', data:'Brand_Name='+BrandID, success: function (html) { parent.find('.Category').html(html); parent.find('.SubCategory').html('<option value="">Select Category first</option>'); parent.find('.Model').html('<option value="">Select Sub_Category first</option>'); } }); } else { parent.find('.Category').html('<option value="">Select Brand first</option>'); parent.find('.SubCategory').html('<option value="">Select Category first</option>'); parent.find('.Model').html('<option value="">Select Sub_Category first</option>'); } }); $(document).on('change', '.Category', function(){ var CategoryID = $(this).val(); var parent = $(this).closest('.parent-container'); var BrandID = parent.find('#Brand').val(); if(CategoryID){ $.ajax({ type:'POST', url:'ajaxData.php', data: 'Category_Name='+CategoryID+'&Brand_Name='+BrandID, success: function (html) { parent.find('.SubCategory').html(html); parent.find('.Model').html('<option value="">Select Sub_Category first</option>'); } }); } else { parent.find('.SubCategory').html('<option value="">Select Category first</option>'); parent.find('.Model').html('<option value="">Select Sub_Category first</option>'); } }); $(document).on('change', '.SubCategory', function(){ var SubCategoryID = $(this).val(); var parent = $(this).closest('.parent-container'); var BrandID = parent.find('#Brand').val(); var CategoryID = parent.find('#Category').val(); if(CategoryID){ $.ajax({ type:'POST', url:'ajaxData.php', data: 'Sub_Category_Name='+SubCategoryID+'&Category_Name='+CategoryID+'&Brand_Name='+BrandID, success: function (html) { parent.find('.Model').html(html); } }); } else { parent.find('.Model').html('<option value="">Select Sub_Category first</option>'); } }); </script>
  17. Dear Gyver, As per your instruction i modified the code. My modified code is $(document).on('change', '.Brand', function(){ //var BrandID = $(this).val(); var parent = $(this).closest('.parent-container'); if(parent){ $.ajax({ type:'POST', url:'ajaxData.php', data:'Brand_ID='+parent, success: function (html) { parent.find('.Category').html(html); parent.find('.test').html('<option value="">Select Category first</option>'); parent.find('.Model').html('<option value="">Select Sub_Category first</option>'); } }); } else { parent.find('.Category').html('<option value="">Select Brand first</option>'); parent.find('.test').html('<option value="">Select Category first</option>'); parent.find('.Model').html('<option value="">Select Sub_Category first</option>'); } }); When i am selecting Brand, the brand id is posting as object. pls refer the below image kindly modify my code this time
  18. Dear Team, Now i am getting output for all the four drop down list based on the selection of previous dropdown. My final code is <?php session_start(); //error_reporting(0); error_reporting(E_ALL); ini_set('display_errors', '1'); //ini_set('display_errors','Off'); include("../connection.php"); include("../paginator.class.php"); $id=$_SESSION['id']; if($_SESSION['id'] == '') { session_destroy(); // header("location:logout.php"); //redirect to index.php } $query=mysqli_query($conn,"SELECT * FROM users where id='$id'"); $row=mysqli_fetch_array($query); $Name = $row['Name']; $Emp_No = $row['Emp_No']; $Designation = $row['Designation']; $Type = $row['User_Type']; $Type1 = $row['User_Type']; $Branch = $row['Branch']; $Approver = $row['Approver']; ?> <!DOCTYPE html> <!-- Created by CodingLab |www.youtube.com/CodingLabYT--> <html lang="en" dir="ltr"> <head> <meta charset="UTF-8"> <!--<title> Drop Down Sidebar Menu | CodingLab </title>--> <link rel="stylesheet" href="css/tiv.css"> <!-- Boxiocns CDN Link --> <link href='https://unpkg.com/boxicons@2.0.7/css/boxicons.min.css' rel='stylesheet'> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.9.4/Chart.js"></script> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css" /> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.3/jquery.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script> <script src="https://canvasjs.com/assets/script/canvasjs.min.js"></script> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script> <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script> </head> <body> <div class="sidebar"> <div class="logo-details"> <img src="Image/Schwing_Logo.jpg" style="height:30px; width:100px; margin-left:10px; margin-top:0px" /> <img src="Image/XCMG_LOGO.png" style="height:30px; width:100px; margin-left:10px; margin-top:0px" /> </div> <ul class="nav-links"> <li> <a href="Dashboard.php" > <i class='bx bxs-dashboard'></i> <span class="link_name">Dashboard</span> </a> </li> <li> <a href="TIV.php" class="active"> <i class='bx bx-trending-up'></i> <span class="link_name">TIV Sales Data</span> </a> </li> <li> <a href="Marketing.php"> <i class='bx bxs-business'></i> <span class="link_name">Marketing & Promotion</span> </a> </li> <li> <a href="PartsandService.php"> <i class='bx bxs-wrench'></i> <span class="link_name">Parts & Service</span> </a> </li> <li> <a href="Manpower.php"> <i class='bx bxs-user-detail'></i> <span class="link_name">Manpower</span> </a> </li> <li> <a href="Manpower.php"> <i class='bx bx-book'></i> <span class="link_name">Equipement & Population</span> </a> </li> <li> <div class="iocn-link"> <a href="#"> <i class='bx bx-wallet-alt'></i> <span class="link_name">Expenses</span> </a> <i class='bx bxs-chevron-down arrow' ></i> </div> <ul class="sub-menu"> <li><a href="Employee_Expense.php">Employee Expense</a></li> <li><a href="Infrastructural_Expense.php">Infrastructural Expense</a></li> <li><a href="Other_Expense.php">Other Expense</a></li> </ul> </li> <li> <a href="#"> <i class='bx bxs-report'></i> <span class="link_name">Reports</span> </a> </li> <li> <div class="profile-details"> <div class="profile-content"> <!--<img src="image/profile.jpg" alt="profileImg">--> </div> <div class="name-job"> <div class="profile_name"><?php echo $Name; ?></div> <div class="job"><?php echo $Designation; ?></div> </div> <a href="Logout.php"> <i class='bx bx-log-out'></i> </a> </div> </li> </ul> </div> <section class="home-section"> <nav> <div class="home-content" style="margin-top:15px"> <span class="text">TIV Sales Data</span> </div> </nav> <br /> <!-- Body Content--> <div class="main" style="top:50px;bottom:20px"> <div> <form method="POST" action=""> <p>Select Month: <input type="month" name="month" placeholder="Select Month" required style="width:auto;border:solid; border-color:black;font-family:Cambria;border-radius:5px;height:30px" /> </p> <table class="table"> <tr> <th style="width:50px">#</th> <th>District</th> <th>Brand</th> <th>Category</th> <th>Sub Category</th> <th>Model</th> <th style="width:80px">Quantity</th> <th>Average Selling Price</th> </tr> <tbody id="tbody"> <template id="row-template"> <tr style="text-align: center" class="parent-container"> <td></td> <td> <select class="background" name="District[]"> <option value="">District</option> </select> </td> <td> <select id="Brand" name="Brand[]" class="Brand"> <option value="">Select Brand</option> <?php $query = "SELECT * FROM brand ORDER BY Brand_Name ASC"; $result = $conn->query($query); if($result->num_rows > 0){ while($row = $result->fetch_assoc()){ echo '<option value="'.$row['Brand_ID'].'">'.$row['Brand_Name'].'</option>'; } }else{ echo '<option value="">Country not available</option>'; } ?> </select> </td> <td> <select id="Category" name="Category[]" class="Category"> <option value="">Select Brand first</option> </select> </td> <td> <select id="test" name="test[]" class="test"> <option value="">Select Category first</option> </select> </td> <td> <select id="Model" name="Model[]" class="Model"> <option value="">Select Sub-Category first</option> </select> </td> <td><input type='number' name="Quantity[]"></td> <td><input type='number' name="ASP[]"></td> <td hidden align='center' style="width:10%"> <input type="checkbox" checked="checked" class="checkbox" name='lang[]' value="" /> </td> </tr> </template> </tbody> </table> <div style="text-align:center"> <button type="button" onclick="addItem();" style="font-family:Cambria;float:left;background: #0A2558;color:white;cursor:pointer; height:30px; border-radius:5px; padding:5px">Add New<i class='bx bx-plus-medical' style="margin-left:10px"></i></button> <input type="submit" name="addInvoice" value="Submit" style="width:100px;background: #0A2558; color:white;font-family:Cambria;border-radius:5px;height:30px;" /> </div> </form> <?php if (isset($_POST["addInvoice"])) { $month = $_POST["month"]; $Dealername = $Name; $newDate = date("M-Y", strtotime($month)); //for ($a = 0; $a < count($_POST["lang"]); $a++) foreach($_POST['lang'] as $ID => $VAL){ $Brand = $_POST['Brand'] [$ID]; $Category = $_POST['Category'] [$ID]; $Sub_Category = $_POST['Sub_Category'] [$ID]; $Model = $_POST['Model'] [$ID]; $Quantity = $_POST['Quantity'] [$ID]; $ASP = $_POST['ASP'] [$ID]; $District = $_POST['District'] [$ID]; $sql = "INSERT INTO tiv (Month, Brand, Category, Sub_Category, Model, Quantity, Dealer_Name, District, ASP) VALUES ('$newDate', '$Brand', '$Category', '$Sub_Category', '$Model', '$Quantity', '$Dealername', '$District', '$ASP')"; mysqli_query($conn, $sql); } } ?> <script> const template=document.getElementById('row-template'); const tbody=document.getElementById('tbody'); let itemCount=0; function addItem(){ const newRow = template.content.cloneNode(true); const firstTd = newRow.querySelector('td:first-child'); firstTd.textContent=++itemCount; tbody.appendChild(newRow); } </script> </div> </div> </section> <script> $(document).on('change', '#Brand', function(){ var BrandID = $(this).val(); if(BrandID){ $.ajax({ type:'POST', url:'ajaxData.php', data:'Brand_ID='+BrandID, success: function (html) { $('#Category').html(html); $('#test').html('<option value="">Select Category first</option>'); $('#Model').html('<option value="">Select Sub_Category first</option>'); } }); } else { $('#Category').html('<option value="">Select Brand first</option>'); $('#test').html('<option value="">Select Category first</option>'); $('#Model').html('<option value="">Select Sub_Category first</option>'); } }); $(document).on('change', '#Category', function(){ var CategoryID = $(this).val(); var BrandID = $('#Brand').val(); if(CategoryID){ $.ajax({ type:'GET', url:'ajaxData.php', //data: 'Category_ID=' + CategoryID, data: 'Category_ID='+CategoryID+'&Brand_ID='+BrandID, success: function (html) { $('#test').html(html); $('#Model').html('<option value="">Select Sub_Category first</option>'); } }); } else { $('#test').html('<option value="">Select Category first</option>'); $('#Model').html('<option value="">Select Sub_Category first</option>'); } }); $(document).on('change', '#test', function(){ var subCategoryID = $(this).val(); var CategoryID = $('#Category').val(); var BrandID = $('#Brand').val(); if(subCategoryID){ $.ajax({ type:'GET', url:'ajaxData.php', //data: 'Category_ID=' + CategoryID, data: 'Sub_Category_ID='+subCategoryID+'&Brand_ID='+BrandID, success: function (html) { $('#Model').html(html); } }); } else { $('#Model').html('<option value="">Select Sub_Category first</option>'); } }); </script> <script> function Category_click_click(){ value_select = $("#Category_click").val(); $.post('TIV.php',{"Category_click":value_select},function(data){ }) } </script> <script> let arrow = document.querySelectorAll(".arrow"); for (var i = 0; i < arrow.length; i++) { arrow[i].addEventListener("click", (e)=>{ let arrowParent = e.target.parentElement.parentElement;//selecting main parent of arrow arrowParent.classList.toggle("showMenu"); }); } </script> </body> </html> <?php // Include the database config file include("../connection.php"); //error_reporting(0); error_reporting(E_ALL); ini_set('display_errors', '1'); //ini_set('display_errors','Off'); if(!empty($_POST["Brand_ID"])){ $Brand =$_POST["Brand_ID"]; // Fetch state data based on the specific country // Generate HTML of state options list $query = "SELECT distinct Category_Name, Category_ID FROM model WHERE Brand_ID = '$Brand' "; $result = $conn->query($query); if($result->num_rows > 0){ echo '<option value="">Select Category</option>'; while($row = $result->fetch_assoc()){ // echo '<option value="'.$row['Category_ID'].'">'.$row['Category_Name'].'</option>'; echo '<option value="' . $row['Category_ID'] . '">' . $row['Category_Name'] . '</option>'; } }else{ echo '<option value="">Category not available</option>'; } }elseif(isset($_GET['Category_ID'])){ $Brand =$_GET["Brand_ID"]; $Category =$_GET["Category_ID"]; // Fetch city data based on the specific state $query = "SELECT distinct Sub_Category_Name, Sub_Category_ID FROM model WHERE Category_ID = '$Category' AND Brand_ID = '$Brand' "; $result = $conn->query($query); // Generate HTML of city options list if($result->num_rows > 0){ echo '<option value="">Select Sub-Category</option>'; while($row = $result->fetch_assoc()){ echo '<option value="'.$row['Sub_Category_ID'].'">'.$row['Sub_Category_Name'].'</option>'; } }else{ echo '<option value="">Sub-Category Not Available</option>'; } }elseif(isset($_GET['Sub_Category_ID'])){ $Brand =$_GET["Brand_ID"]; // $Category =$_GET["Category_ID"]; $Sub_Category =$_GET["Sub_Category_ID"]; // Fetch city data based on the specific state $query = "SELECT distinct Model_Name, Model_ID FROM model WHERE Sub_Category_ID = '$Sub_Category' AND Brand_ID = '$Brand' "; $result = $conn->query($query); // Generate HTML of city options list if($result->num_rows > 0){ echo '<option value="">Select Model</option>'; while($row = $result->fetch_assoc()){ echo '<option value="'.$row['Model_ID'].'">'.$row['Model_Name'].'</option>'; } }else{ echo '<option value="">Model Not Available</option>'; } } ?> But the other problem i am facing on this is the drop down is not working for newly added row. If i select the brand in newly added row, it is changing the value of my first row. But it shout change the row where i selected it. please help me how to populate the datan on which row i am selecting
  19. Dear Ginerjm, I turned ON the error reporting and fount the mistakes and corrected. Now all my drop downs are populating the values. But it is dosplaying on forst row only. If i add additional rows and select the brand, then it is changing the values on forst row only. It is not changing on my newly added row.
  20. My modified code is <?php session_start(); //error_reporting(0); error_reporting(E_ALL); ini_set('display_errors', '1'); //ini_set('display_errors','Off'); include("../connection.php"); include("../paginator.class.php"); $id=$_SESSION['id']; if($_SESSION['id'] == '') { session_destroy(); // header("location:logout.php"); //redirect to index.php } $query=mysqli_query($conn,"SELECT * FROM users where id='$id'"); $row=mysqli_fetch_array($query); $Name = $row['Name']; $Emp_No = $row['Emp_No']; $Designation = $row['Designation']; $Type = $row['User_Type']; $Type1 = $row['User_Type']; $Branch = $row['Branch']; $Approver = $row['Approver']; ?> <!DOCTYPE html> <!-- Created by CodingLab |www.youtube.com/CodingLabYT--> <html lang="en" dir="ltr"> <head> <meta charset="UTF-8"> <!--<title> Drop Down Sidebar Menu | CodingLab </title>--> <link rel="stylesheet" href="css/tiv.css"> <!-- Boxiocns CDN Link --> <link href='https://unpkg.com/boxicons@2.0.7/css/boxicons.min.css' rel='stylesheet'> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.9.4/Chart.js"></script> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css" /> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.3/jquery.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script> <script src="https://canvasjs.com/assets/script/canvasjs.min.js"></script> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script> <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script> </head> <body> <div class="sidebar"> <div class="logo-details"> <img src="Image/Schwing_Logo.jpg" style="height:30px; width:100px; margin-left:10px; margin-top:0px" /> <img src="Image/XCMG_LOGO.png" style="height:30px; width:100px; margin-left:10px; margin-top:0px" /> </div> <ul class="nav-links"> <li> <a href="Dashboard.php" > <i class='bx bxs-dashboard'></i> <span class="link_name">Dashboard</span> </a> </li> <li> <a href="TIV.php" class="active"> <i class='bx bx-trending-up'></i> <span class="link_name">TIV Sales Data</span> </a> </li> <li> <a href="Marketing.php"> <i class='bx bxs-business'></i> <span class="link_name">Marketing & Promotion</span> </a> </li> <li> <a href="PartsandService.php"> <i class='bx bxs-wrench'></i> <span class="link_name">Parts & Service</span> </a> </li> <li> <a href="Manpower.php"> <i class='bx bxs-user-detail'></i> <span class="link_name">Manpower</span> </a> </li> <li> <a href="Manpower.php"> <i class='bx bx-book'></i> <span class="link_name">Equipement & Population</span> </a> </li> <li> <div class="iocn-link"> <a href="#"> <i class='bx bx-wallet-alt'></i> <span class="link_name">Expenses</span> </a> <i class='bx bxs-chevron-down arrow' ></i> </div> <ul class="sub-menu"> <li><a href="Employee_Expense.php">Employee Expense</a></li> <li><a href="Infrastructural_Expense.php">Infrastructural Expense</a></li> <li><a href="Other_Expense.php">Other Expense</a></li> </ul> </li> <li> <a href="#"> <i class='bx bxs-report'></i> <span class="link_name">Reports</span> </a> </li> <li> <div class="profile-details"> <div class="profile-content"> <!--<img src="image/profile.jpg" alt="profileImg">--> </div> <div class="name-job"> <div class="profile_name"><?php echo $Name; ?></div> <div class="job"><?php echo $Designation; ?></div> </div> <a href="Logout.php"> <i class='bx bx-log-out'></i> </a> </div> </li> </ul> </div> <section class="home-section"> <nav> <div class="home-content" style="margin-top:15px"> <span class="text">TIV Sales Data</span> </div> </nav> <br /> <!-- Body Content--> <div class="main" style="top:50px;bottom:20px"> <div> <form method="POST" action=""> <p>Select Month: <input type="month" name="month" placeholder="Select Month" required style="width:auto;border:solid; border-color:black;font-family:Cambria;border-radius:5px;height:30px" /> </p> <table class="table"> <tr> <th style="width:50px">#</th> <th>District</th> <th>Brand</th> <th>Category</th> <th>Sub Category</th> <th>Model</th> <th style="width:80px">Quantity</th> <th>Average Selling Price</th> </tr> <tbody id="tbody"> <template id="row-template"> <tr style="text-align: center" class="parent-container"> <td></td> <td> <select class="background" name="District[]"> <option value="">District</option> </select> </td> <td> <select id="Brand" name="Brand[]" class="Brand"> <option value="">Select Brand</option> <?php $query = "SELECT * FROM brand ORDER BY Brand_Name ASC"; $result = $conn->query($query); if($result->num_rows > 0){ while($row = $result->fetch_assoc()){ echo '<option value="'.$row['Brand_ID'].'">'.$row['Brand_Name'].'</option>'; } }else{ echo '<option value="">Country not available</option>'; } ?> </select> </td> <td> <select id="Category" name="Category[]" class="Category"> <option value="">Select Brand first</option> </select> </td> <td> <select id="Sub_Category" name="Sub_Category[]" class="Sub_Category"> <option value="">Select Category first</option> </select> </td> <td> <select id="Model" name="Model[]" class="Model"> <option value="">Select Sub-Category first</option> </select> </td> <td><input type='number' name="Quantity[]"></td> <td><input type='number' name="ASP[]"></td> <td hidden align='center' style="width:10%"> <input type="checkbox" checked="checked" class="checkbox" name='lang[]' value="<?php echo $ID; ?>" /> </td> </tr> </template> </tbody> </table> <div style="text-align:center"> <button type="button" onclick="addItem();" style="font-family:Cambria;float:left;background: #0A2558;color:white;cursor:pointer; height:30px; border-radius:5px; padding:5px">Add New<i class='bx bx-plus-medical' style="margin-left:10px"></i></button> <input type="submit" name="addInvoice" value="Submit" style="width:100px;background: #0A2558; color:white;font-family:Cambria;border-radius:5px;height:30px;" /> </div> </form> <?php if (isset($_POST["addInvoice"])) { $month = $_POST["month"]; $Dealername = $Name; $newDate = date("M-Y", strtotime($month)); //for ($a = 0; $a < count($_POST["lang"]); $a++) foreach($_POST['lang'] as $ID => $VAL){ $Brand = $_POST['Brand'] [$ID]; $Category = $_POST['Category'] [$ID]; $Sub_Category = $_POST['Sub_Category'] [$ID]; $Model = $_POST['Model'] [$ID]; $Quantity = $_POST['Quantity'] [$ID]; $ASP = $_POST['ASP'] [$ID]; $District = $_POST['District'] [$ID]; $sql = "INSERT INTO tiv (Month, Brand, Category, Sub_Category, Model, Quantity, Dealer_Name, District, ASP) VALUES ('$newDate', '$Brand', '$Category', '$Sub_Category', '$Model', '$Quantity', '$Dealername', '$District', '$ASP')"; mysqli_query($conn, $sql); } } ?> <script> const template=document.getElementById('row-template'); const tbody=document.getElementById('tbody'); let itemCount=0; function addItem(){ const newRow = template.content.cloneNode(true); const firstTd = newRow.querySelector('td:first-child'); firstTd.textContent=++itemCount; tbody.appendChild(newRow); } </script> </div> </div> </section> <script> $(document).on('change', '.Brand', function(){ var BrandID = $(this).val(); if(BrandID){ $.ajax({ type:'POST', url:'ajaxData.php', data:'Brand_ID='+BrandID, success: function (html) { $('#Category').html(html); $('#Sub_Category').html('<option value="">Select Category first</option>'); $('#Model').html('<option value="">Select Sub_Category first</option>'); } }); } else { $('#Category').html('<option value="">Select Brand first</option>'); $('#Sub_Category').html('<option value="">Select Category first</option>'); $('#Model').html('<option value="">Select Sub_Category first</option>'); } }); $(document).on('change', '.Category', function(){ var CategoryID = $(this).val(); if(CategoryID){ $.ajax({ type:'POST', url:'ajaxData.php', data:'Category_ID='+CategoryID, success: function (html) { $('#Sub_Category').html(html); $('#Model').html('<option value="">Select Sub_Category first</option>'); } }); } else { $('#Sub_Category').html('<option value="">Select Category first</option>'); $('#Model').html('<option value="">Select Sub_Category first</option>'); } }); $(document).on('change', '.Sub_Category', function(){ var Sub_CategoryID = $(this).val(); if(Sub_CategoryID){ $.ajax({ type:'POST', url:'ajaxData.php', data:'Sub_Category_ID='+Sub_CategoryID, success: function (html) { $('#Model').html(html); } }); } else { BrandID.find('.Model').html('<option value="">Select Sub_Category first</option>'); } }); </script> <script> function Category_click_click(){ value_select = $("#Category_click").val(); $.post('TIV.php',{"Category_click":value_select},function(data){ }) } </script> <script> function Sub_Category_click(){ value_select = $("#Sub_Category").val(); $.post('TIV.php',{"Sub_Category":value_select},function(data){ }) } </script> <script> let arrow = document.querySelectorAll(".arrow"); for (var i = 0; i < arrow.length; i++) { arrow[i].addEventListener("click", (e)=>{ let arrowParent = e.target.parentElement.parentElement;//selecting main parent of arrow arrowParent.classList.toggle("showMenu"); }); } let sidebar = document.querySelector(".sidebar"); let sidebarBtn = document.querySelector(".bx-menu"); console.log(sidebarBtn); sidebarBtn.addEventListener("click", ()=>{ sidebar.classList.toggle("close"); }); </script> </body> </html> <?php // Include the database config file include("../connection.php"); //error_reporting(0); error_reporting(E_ALL); ini_set('display_errors', '1'); //ini_set('display_errors','Off'); if(!empty($_POST["Brand_ID"])){ // Fetch state data based on the specific country // Generate HTML of state options list $query = "SELECT distinct Category_Name FROM model WHERE Brand_ID = ".$_POST['Brand_ID']." "; $result = $conn->query($query); if($result->num_rows > 0){ echo '<option value="">Select Category</option>'; while($row = $result->fetch_assoc()){ echo '<option value="'.$row['Category_ID'].'">'.$row['Category_Name'].'</option>'; } }else{ echo '<option value="">Category not available</option>'; } }elseif(!empty($_POST["Category_ID"])){ // Fetch city data based on the specific state $query = "SELECT distinct Sub_Category_Name FROM model WHERE Sub_Category_ID = ".$_POST['Category_ID']." "; $result = $conn->query($query); // Generate HTML of city options list if($result->num_rows > 0){ echo '<option value="">Select Sub-Category</option>'; while($row = $result->fetch_assoc()){ echo '<option value="'.$row['Sub_Category_ID'].'">'.$row['Sub_Category_Name'].'</option>'; } }else{ echo '<option value="">Sub-Category available</option>'; } }elseif(!empty($_POST["Sub_Category_ID"])){ // Fetch city data based on the specific state $query = "SELECT distinct Model_Name FROM model WHERE Model_ID = ".$_POST['Sub_Category_ID']." "; $result = $conn->query($query); // Generate HTML of city options list if($result->num_rows > 0){ echo '<option value="">Select Model</option>'; while($row = $result->fetch_assoc()){ echo '<option value="'.$row['Model_ID'].'">'.$row['Model_Name'].'</option>'; } }else{ echo '<option value="">Model available</option>'; } } ?> Pls look on it. If you found any mistakes, pls correct it
  21. I changed the code as per your Instructions. I don't know how to do it exactly. Can you please modify my code and post it for me
  22. I checked with debugging my side. But no result. Can you please check and modify my code
  23. I turned ON the error reporting. But it is not sohwing any error. Also When i am selecting Brand it is working (Category list is populating) on first row only. If i add more rows, the category list is not populating on the newly added row. It is populating the list on fir row only even if is change the brand on 2nd row. Please help me
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.