Jump to content

Convert search to type ahead and submit...


asevie

Recommended Posts

I'm converting a search feature that currently uses two successive dropdown fields to do the search. The search is initiated when the user selects the option from the dropdown. The resultant (it's always 1 record) is then displayed in detail with a + sign next to it so that the user can add the record he just searched for.

 

I've replaced it with a single dropdown and type-ahead field that uses javascript. The type ahead replaces the second drop down. I didn't want users have to select amongst hundreds of records in a drop down, by forcing them to start typing the second drop down, I can narrow the results to the exact item the user is looking for.

 

My problem is that I'm not sure how to get the type ahead result to initiate the search on the user select. I initiate it like this in the old version...

 

            <table>

                <tr>

                    <td width="130px" valign="top"><form name="nav"><select name="platform" id="platform" onChange="document.location.href=document.nav.platform.options[document.nav.platform.selectedIndex].value">

                        <option>Platform</option>

                        <?

                            $result = mysql_query("SELECT * FROM Platform");

                            while($row = mysql_fetch_array($result)) {

                        ?>

                        <option value="?ptfm_ctrl=1&ptfm_id=<?=$row['id_platform']?>" <? if ($_GET['ptfm_id']==$row['id_platform']) { ?>selected="selected"<? } ?>><?=$row['platform']?></option>

                        <? } ?>

                    </select></form></td>                   

                    <?

                        if (isset($_GET["ptfm_ctrl"])) {

                    ?>

<tr>

</table>

 

 

 

The new solution generates the type ahead result like this...

 

<div>

<form>

<div>

Start typing the name of the product, select the correct title when it appears:

<br />

<input type="text" size="30" value="" id="inputString" onkeyup="lookup(this.value);" onblur="fill();" />

</div>

 

<div class="suggestionsBox" id="suggestions" style="display: none;">

<img src="upArrow.png" style="position: relative; top: -12px; left: 30px;" alt="upArrow" />

<div class="suggestionList" id="autoSuggestionsList">

 

</div>

</div>

</form>

</div>

 

How can I initiate the search using the second method?

 

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.