ben_1uk Posted November 20, 2013 Share Posted November 20, 2013 Hello everyone, I'm hoping someone here can help me with the below change I have been tasked with to amend an existing product filter on a works website. Currently, the script filters by product code, but NOT by product description - not very helpful for our customers. As such, I have been asked if this can be changed. Trouble is, I didn't create the code in the first place, so I'm a little wary of getting stuck in! From what I can see, upon entering a product code, the 'Product Description' field updates in real time, filtering product matching that code. Here is the HTML code from the page that generates the order form: <div id='order_container'><input type='button' name='clickyclickclick' value='Load Order' onclick='MakeRequestOrder();' /></div> ...and here is a PHP script that appears to be linked to the above form: if ($o['user_can_amend'] == 'N') { echo "<div class='error'>You cannot make changes to this order now.</div>"; header("Location: index.php?option=orders&order=" . $_GET['order']); } else { $additional_header.= " <script type='text/javascript' src='index.php?option=orders&order=" . $order_id . "&js' ></script> <script type='text/javascript'>MakeRequestOrder();</script>"; echo "<div id='order_container'><input type='button' name='clickyclickclick' value='Load Order' onclick='MakeRequestOrder();' /></div>"; $body_addition .= "onload='MakeRequestOrder();' "; ...and below is the code that appears to be handling the actual function of the filter itself: <div id="order_container"> <form name="order"> <table class="order_content_header"> <tbody> <tr> … </tr> <tr> … </tr> <tr class="order_content_odd"> <td class="code_box"> … </td> <td> <div id="product_container"> <select onchange="javascript: UpdateCode(this.value);" name="description"> … </select> <input type="hidden" value="0" name="product_id"></input> </div> </td> <td> … </td> <td> … </td> </tr> <tr class="order_content_total"> … </tr> </tbody> </table> </form> </div> There appears to only be a filter option for table class 'code_box' but nothing for 'description'. Can anyone please help me? Thank you, Ben_1uk Quote Link to comment Share on other sites More sharing options...
Muddy_Funster Posted November 20, 2013 Share Posted November 20, 2013 pretty much none of that code is relevant to filtering the search, or even returning the value list in the first place. From what you have posted it looks like your first point of call should be the JavaScript function UpdateCode() - can you post up the code for that? On a side note - whoever named a button "clickyclickclick" on a production script needs slapped. Quote Link to comment Share on other sites More sharing options...
ben_1uk Posted November 20, 2013 Author Share Posted November 20, 2013 pretty much none of that code is relevant to filtering the search, or even returning the value list in the first place. From what you have posted it looks like your first point of call should be the JavaScript function UpdateCode() - can you post up the code for that? On a side note - whoever named a button "clickyclickclick" on a production script needs slapped. Hi Muddy_Funster, Is this the code you are referring to? function UpdateCode(code) { document.order.item_code.value = code; MakeRequestProducts(code); } Quote Link to comment Share on other sites More sharing options...
Muddy_Funster Posted November 20, 2013 Share Posted November 20, 2013 yeah, but you'll need to follow the code through all the functions that it processes, so next up is MakeRequestProducts() Quote Link to comment Share on other sites More sharing options...
ben_1uk Posted November 20, 2013 Author Share Posted November 20, 2013 (edited) yeah, but you'll need to follow the code through all the functions that it processes, so next up is MakeRequestProducts() Thank for your help so far. Here is the code handling the MakeRequestProducts function: function MakeRequestProducts(code) { var xmlHttp = getXMLHttp(); xmlHttp.onreadystatechange = function() { if (xmlHttp.readyState == 4) { HandleResponse(xmlHttp.responseText, 'product_container'); document.order.item_code.focus(); } } xmlHttp.open("GET", "index.php?option=orders&order=<?php echo $_GET['order']; ?>&products&item_code=" + code , true); xmlHttp.send(null); } Is HandleResponse relevant? Edited November 20, 2013 by ben_1uk Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.