Page 1 of 1

multi-field dropdown and dropdown

Posted: 2012-10-03 17:21
by antonio
Hi all,
I have a page that has a dropdown menu and lots of text fields.
I populate all text fields using multi-field dropdown and it works great.

Example:

Code: Select all

MAIN DROPDOWN MENU (will fill all fields below):

- textfield 1
- textfield 2
- textfield 3
- textfield 4
- textfield 5
But now I need to add another field (dropdown) to the existing text fields.
My question: will the multi-field dropdown field update the text field AND the dropdown menu field?

Example:

Code: Select all

MAIN DROPDOWN MENU (will fill all fields below):

- textfield 1
- textfield 2
- textfield 3
- textfield 4
- textfield 5
- dropdown menu field
I cannot test it right now, but I would like to know if it could work or not.

Any suggestion will be appreciated.

Thanks in advance.

Antonio

Re: multi-field dropdown and dropdown

Posted: 2012-10-04 17:17
by antonio
Hi all,
I just tried to add a dropdown field but the Multi-field drop-down doesn't wotk with select field (only text ot textarea field) :(

Is there a way to get something similar?
All I want to get is the user to select an item from a drop down to populate some other fields.
All those field are editable and the user can edit them (of course...).
The user can save all data in these fields to a (sort of) address book so that he has not to enter an address manually every time.
Once added to the address book the main drop down menu gets updated with the new entry. Re-selecting the new entry will populate all other fields accordingly.
This works beautifully.

But I need to be sure the user enter the correct COUNTRY in a specific field. Since then I need to check it.
So, if someone write "Italy" is ok, but if someone else write "Italia" it is not correct. I cannot filter all Countries this way.
That's why I would use a dropdown menu for the country field.
But the multi-field dropdown behaviuour doesn't work with menus (only text field or textarea fields).

Any idea will be really appreciated.

ciao

tony

Re: multi-field dropdown and dropdown

Posted: 2012-10-05 14:03
by Fred
Tony,
Here is an auto-suggest script that I use to search for something in a text field.

You would need jquery

The script on the page

Code: Select all

<script>
$(document).ready(function() {
    $.fn.autosugguest({  
           className: 'ausu-suggest',
          methodType: 'POST',
            minChars: 1,
              rtnIDs: true,
            dataFile: 'ajax_contacts.php'
    });
});
</script>
The code in the form

Code: Select all

<div class="ausu-suggest">
	<input class="type_data" type="text" size="25" value="<?php echo $row_rs_distributor['dist_name']; ?>" name="distributors" id="distributors" autocomplete="on"/>
	<input type="hidden" size="4" value="<?php echo $row_rsopp_main['opp_distributer_id']; ?>" name="opp_distributer_id_<?php echo $cnt1; ?>" id="opp_distributer_id_<?php echo $cnt1; ?>" autocomplete="off"/>
        <a class="fancybox fancybox.iframe" href="ajax_add_distributor.php"><img src="../images/add_buriness_record.png" border="0"></a>
</div>
The ajax_contacts.php file

Code: Select all

<?php require_once('../Conn/siteConn.php'); ?>
<?php

mysql_select_db($database_siteConn, $siteConn);

# Assign local variables
$id     =   @$_POST['id'];          // The id of the input that submitted the request.
$data   =   @$_POST['data'];        // The value of the textbox.

if ($id && $data)
{
    if ($id=='distributors')
    {
        $query  = "SELECT dist_id, dist_name FROM opp_distributors WHERE dist_name LIKE '$data%' LIMIT 10";
        $result = mysql_query($query);
        $dataList = array();
        while ($row = mysql_fetch_array($result))
        {
            $toReturn   = $row['dist_name'];
            $dataList[] = '<li id="' .$row['dist_id'] . '"><a href="#">' . htmlentities($toReturn) . '</a></li>';
        }
        if (count($dataList)>=1)
        {
            $dataOutput = join("\r\n", $dataList);
            echo $dataOutput;
        }
        else
        {
            echo '<li><a href="#">No Results - Please click the icon to add</a></li>';
        }
    } elseif ($id=='dealers')
    {
        $query  = "SELECT deal_id, deal_name FROM opp_dealer WHERE deal_name LIKE '$data%' LIMIT 10";
        $result = mysql_query($query);
        $dataList = array();
        while ($row = mysql_fetch_array($result))
        {
            $toReturn   = $row['deal_name'];
            $dataList[] = '<li id="' .$row['deal_id'] . '"><a href="#">' . htmlentities($toReturn) . '</a></li>';
        }
        if (count($dataList)>=1)
        {
            $dataOutput = join("\r\n", $dataList);
            echo $dataOutput;
        }
        else
        {
            echo '<li><a href="#">No Results - Please click the icon to add</a></li>';
        }
	 } elseif ($id=='end_users')
    {
        $query  = "SELECT eu__id, eu_name_name FROM opp_end_user WHERE eu_name_name LIKE '$data%' LIMIT 10";
        $result = mysql_query($query);
        $dataList = array();
        while ($row = mysql_fetch_array($result))
        {
            $toReturn   = $row['eu_name_name'];
            $dataList[] = '<li id="' .$row['eu__id'] . '"><a href="#">' . htmlentities($toReturn) . '</a></li>';
        }
        if (count($dataList)>=1)
        {
            $dataOutput = join("\r\n", $dataList);
            echo $dataOutput;
        }
        else
        {
            echo '<li><a href="#">No Results - Please click the icon to add</a></li>';
        }
		}
}
?>

Re: multi-field dropdown and dropdown

Posted: 2012-10-05 14:11
by antonio
Thanks Fred,
I'll try that.

Ciao

tony

Re: multi-field dropdown and dropdown

Posted: 2012-10-05 14:15
by Fred
Here is a working example of a site I did ages ago and busy updating a bit.
http://www.fosteraero.co.za/

The Aircraft Search function uses the same script, just modified slightly to not update an input field but rather generate a link.