Jump to content

Filtering Poduct Using PHP


ben_1uk

Recommended Posts

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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);
}
Link to comment
Share on other sites

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 by ben_1uk
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.