Jump to content


  • Content Count

  • Joined

  • Last visited

Community Reputation

0 Neutral

About Adamhumbug

  • Rank
  1. Adamhumbug

    Submit large form created with select statement

    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.
  2. 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
  3. 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
  4. Adamhumbug

    Move tr to top of table if input changed

    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); });
  5. 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
  6. HI All, I have a very simple table with 3 cols, it has been created with a select * statement using php. The first col is an item name The second is a quantity The third is a value There is a div that is hidden that is being given a value - probably not the best way. I would like, when you add a number to the quantity field, it gets multiplied by the value (hidden div) and outputs the line total. This is what the html looks like for one line <tr> <td style="width:70%;"> Item Name </td> <td class="text-center"> <input id="moneyQty" type="text" value="2"> </td> <td class="text-center"> <div id="singleValue" style="display:none;"> 90.00 </div><input id="lineTotal" type="text"> </td> </tr> The code i have at the minute is the following. <script> if(document.getElementById('moneyOrderForm')){ var singleValue = document.getElementById('singleValue').innerHTML; console.log(singleValue); var qty = document.getElementById('moneyQty').value; var total = qty * singleValue; console.log(total); document.getElementById('lineTotal').value = total; } </script> This does show me the correct answer in the correct box. The issue i have here is that get element by ID will be no good because there are many items being created. I need a way for this to work accross many lines and havnt a clue how. I know there are many things that need tidying up here but a nudge in the right direction would be appreciated. Kind Regards
  7. Adamhumbug

    Check if textbox is different from database field

    when making the order, they may agree with the client a special menu package. This may have small one off changes. The menu items can be pretty long. Herb crusted Marinated Rump of Lamb, served with petit pois a la francese, roasted baby potato, blistered cherry tomatoes, rich lamb jus They may only want to change roasted to boiled. The chnages should not be selectable by default.
  8. Adamhumbug

    Check if textbox is different from database field

    Yes pretty much, they will have the option to change all or part of the menu
  9. Adamhumbug

    Check if textbox is different from database field

    Yes, they are not ordering food for themselves, they are ordering it for an event.
  10. Adamhumbug

    Check if textbox is different from database field

    What if another user logs in and needs to amend the menu that the first user changed. They would then need all of that session data?
  11. Adamhumbug

    Check if textbox is different from database field

    If i store it in a session though, when the user logs back in and comes to make chnages the sessiona will have been killed. Or am i missing something?
  12. I am building a system where people are able to choose a food menu, they can modify each dish if needed and then say how many of each item they need for the order. So when they pick the breakfast menu, it selects all starters, mains and desserts. Should something need to be edited (sausages changed to vegitarian sausages) the user should be able to overtype what has been populated from the select statement) When the form is submitted, the order needs to be linked to the current job which is in a field ssm_job.job_id but the changes to the menu items need to be stored somewhere for the current order only. This obviously needs to be accessile later so further changes can be made if needed. I am not sure of the best way to go about this as i am trying not to save every item in another database (just trying to be tidy) Any advise on this would be greatly appreciated. I have had help on this project in relation to an sql and the background can be found below, the help has been amazing but as this is a very different question i thought i would start a new thread. Kind Regards
  13. Adamhumbug

    Create table fields with types

    Ok, sounds like a plan. Do i need to change my sql for this or is it something that i do in my php?
  14. Adamhumbug

    Create table fields with types

    Thanks - this is done. So i have been thinking about how to output my results in section in the form having a header of each of the $mitcat (the starter, main, dessert) So i would have the header as it is, then a tr that outputs starter then all the starters under it then a mains header and so on. Is this doable with what i have or have i shot myself in the foot not taking your advice earlier on
  15. Adamhumbug

    Create table fields with types

    I found a way to make it work - looks nasty though but it works. $stmt = $conn->prepare($sql); $stmt->bind_param("s", $_GET['q']); $stmt->execute(); $stmt->store_result(); $stmt->bind_result($mname, $mprice, $mitname, $mitcat); $first = true; while($stmt->fetch()){ if($first) { echo "<form>"; echo "<table class='table table-striped table-hover table-bordered text-center mt-3'>"; echo "<tr>"; echo "<th colspan='5'><div style='width:50%;float:left;'>".$mname."</div><div style='width:50%;float:right;'>".$mprice."</div></th>"; echo "</tr>"; $first = NULL; } echo "<tr>"; echo "<td>" . $mitname . "</td>"; echo "<td>" . $mitcat . "</td>"; echo "<td><input /></td>"; echo "<td><input /></td>"; echo "</tr>"; } echo "</table>"; echo "<input type='submit' action='' class='btn btn-primary' value='Submit'>"; $stmt->close(); ?>

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.