Jump to content

Adamhumbug

Members
  • Posts

    597
  • Joined

  • Last visited

Everything posted by Adamhumbug

  1. So i changed the HTML to be the following to use data[ ] <tr> <td style="width:70%;">Item 1</td> <input type="hidden" name="data[equipmentId]" value="1"> <td class="text-center"> <input name="data[equipmentQty]" class="eqQty text-center up" type="text"> </td> </tr> <tr> <td style="width:70%;">Item 2</td> <input type="hidden" name="data[equipmentId]" value="2"> <td class="text-center"> <input name="data[equipmentQty]" class="eqQty text-center up" type="text"> </td> </tr> And the php $_POST['data']; print_r($_POST['data']); This gives me the following regardless of how many rows i type a quantity into, also, it is not putting the quantity into the array. Also, equipment id 22 is the last item in the table. Array ( [equipmentId] => 22 [equipmentQty] => ) A bit lost
  2. Here is the html <form id="equipmentOrderForm" action="actions/submit-equipment-order-action.php" method="post"> <div class="input-group mt-3 mb-3"> <div class="input-group-prepend"><span class="input-group-text">Search (alt/option+s)</span></div> <input id="equipmentTableSearch" class="form-control" type="text" placeholder="Plates...Soup Spoon...Red Wine Glass..." /><button class="btn btn-primary" name="equipment_submit_button" type="submit">Submit</button></div> <table id="equipmentTable" class="mt-3 table table-striped table-hover table-bordered"> <thead> <tr class="text-center"> <th>Equipment</th> <th>Quantity</th> </tr> </thead> <tbody> <tr> <td style="width:70%;">Item 1</td> <input type="hidden" name="equipmentId[]" value="1"> <td class="text-center"> <input name="equipmentQty[]" class="eqQty text-center up" type="text"> </td> </tr> <tr> <td style="width:70%;">Item 2</td> <input type="hidden" name="equipmentId[]" value="2"> <td class="text-center"> <input name="equipmentQty[]" class="eqQty text-center up" type="text"> </td> </tr> </tbody> </table> </form> Here is the JS function searchEquipmentTable() { // Declare variables var input, filter, table, tr, td, i, txtValue; input = document.getElementById("equipmentTableSearch"); filter = input.value.toUpperCase(); table = document.getElementById("equipmentTable"); tr = table.getElementsByTagName("tr"); // Loop through all table rows, and hide those who don't match the search query for (i = 0; i < tr.length; i++) { td = tr[i].getElementsByTagName("td")[0]; if (td) { txtValue = td.textContent || td.innerText; if (txtValue.toUpperCase().indexOf(filter) > -1) { tr[i].style.display = ""; } else { tr[i].style.display = "none"; } } } }
  3. Hi, Thanks for this. So i have made some changes and have used serialise. I have three things to import per line, the first is an ID and should be the same on every line. The second is the value of a hidden input which will be different per line. The third is the value of a text box which may be different on each line. I do not want to include rows where the number in the input is zero or blank. I have this $jobId = $_SESSION['current_job_id']; $equipmentId = serialize($_POST['equipmentId']); $equipmentQty = serialize($_POST['equipmentQty']); $sql = "INSERT INTO ssm_equipment_order (job_id, equipment_id, equipment_quantity) VALUES ('$jobId', '$equipmentId', '$equipmentQty')"; but when printing $sql i get the following INSERT INTO ssm_equipment_order (job_id, equipment_id, equipment_quantity) VALUES ('25', 'a:22:{i:0;s:1:"2";i:1;s:1:"1";i:2;s:1:"3";i:3;s:1:"4";i:4;s:1:"5";i:5;s:1:"6";i:6;s:1:"7";i:7;s:1:"8";i:8;s:1:"9";i:9;s:2:"10";i:10;s:2:"11";i:11;s:2:"12";i:12;s:2:"13";i:13;s:2:"14";i:14;s:2:"15";i:15;s:2:"16";i:16;s:2:"17";i:17;s:2:"18";i:18;s:2:"19";i:19;s:2:"20";i:20;s:2:"21";i:21;s:2:"22";}', 'a:22:{i:0;s:2:"10";i:1;s:2:"10";i:2;s:0:"";i:3;s:0:"";i:4;s:0:"";i:5;s:0:"";i:6;s:0:"";i:7;s:0:"";i:8;s:0:"";i:9;s:0:"";i:10;s:0:"";i:11;s:0:"";i:12;s:0:"";i:13;s:0:"";i:14;s:0:"";i:15;s:0:"";i:16;s:0:"";i:17;s:0:"";i:18;s:0:"";i:19;s:0:"";i:20;s:0:"";i:21;s:0:"";}') So i feel like i am on the right lines and will keep looking. One thing i am not sure on is how to only include in the array rows where the equipmentQty is not 0 or blank.
  4. Hi, I have many tables that can be searched using an input box. I have been copying and pasting the same code to every page, changing the id for the search box and the id for the table name on each page. Is there a better way of doing this? For reference, here is the search code. function searchTransportTable() { // Declare variables var input, filter, table, tr, td, i, txtValue; input = document.getElementById("transportTableSearch"); filter = input.value.toUpperCase(); table = document.getElementById("transportTable"); tr = table.getElementsByTagName("tr"); // Loop through all table rows, and hide those who don't match the search query for (i = 0; i < tr.length; i++) { td = tr[i].getElementsByTagName("td")[0]; if (td) { txtValue = td.textContent || td.innerText; if (txtValue.toUpperCase().indexOf(filter) > -1) { tr[i].style.display = ""; } else { tr[i].style.display = "none"; } } } } Kind Regards
  5. Hi, I have a very large form that has been created with a select statement. When i am submitting the form and running the sql insert, i obviously cant list out all of the fields like you would for a small form. How would one go about submitting a form with a large number of fields. The code below is one of the lines of the table <tr> <td style="width:70%;"> <span value="1">Item</span> </td> <td class="text-center"> <input class="eqQty text-center up" type="text"> </td> </tr> I am sure that the answer is faily simple but googling has not been friendly to me on this one. Kind Regards
  6. I have found what feels like quite a nasty way of doing what i wanted. $('#equipmentTable input.eqQty').focusout(function() { var row = $(this).closest('tr'); if ($(this).hasClass('up')) row.insertBefore( row.parent().find('tr:first-child') ) .find('label').html('move to bottom'); else row.next().after(row); });
  7. Hi all, I have a table that is being created with a select statement. It has 3 tds, the third being a text box. When the user fills in the textbox i would like it to go to the top of the table. I have found some code that uses checkboxes but as i am very new to js and jq i would really appreciate help on this. I would prefer this to be written in js as i understand it better. The code that i found is below and i have tried to modify it do what i want without any joy. $('table').on('change', '[type=checkbox]', function () { var $this = $(this); var row = $this.closest('tr'); if ( $this.prop('checked') ){ // move to top row.insertBefore( row.parent().find('tr:first-child') ) .find('label').html('move to bottom'); } else { // move to bottom row.insertAfter( row.parent().find('tr:last-child') ) .find('label').html('move to top'); } }); I would appreciate any help with this. Kind Regards
×
×
  • 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.