Welcome Guest, Not a member yet? Register   Sign In
Chained Combobox Select
#1

[eluser]Fielder[/eluser]
I've found a few examples of chained combobox, and am trying to make sense of how they work (I'm Very inexperienced with ajax). For example..
http://www.alexajax.com/dropdownlist
and
http://remysharp.com/2007/09/18/auto-pop...ect-boxes/

Do you guys have a recommendation for a method to create chained comboboxes?

Ultimately I want the user to drill down to their final selection in the chained comboboxes, click "Add" and the entry added to be displayed below. Then reselect through the chained comboboxes again, click "Add" and add another entry below the previous. Once all necessary entries are done, they click Finalize and the entire page is posted and all the selections made are entered into a database.

Any thoughts/recommendations on how to accomplish this?
#2

[eluser]depthcharge[/eluser]
Both your example url's have incorrect address's, i.e http://http:// :ohh:

I think the examples on the first link kind of give you what you need.

I personally would not leave the database insertion until they are finished, I would add the new additions to the database as they are entered and do some kind of ajax refresh before any additional new entries are made.
Code:
click “Add” and the entry IS INSERTED INTO DATABASE AND added to be displayed below
#3

[eluser]Colin Williams[/eluser]
Instead of a broad request like this, what specific bit of code/logic are you hung up on?
#4

[eluser]Fielder[/eluser]
I walked myself through the code and figured the xajax out. However, I'm having a problem, maybe an easy solution??? anyone..

When the user selects a store name from the FIRST combo box, it runs a dbase query and displays the store numbers in a SECOND combo box based on the store name from the FIRST.
Code:
function storename_name_onchange($storename_name)
    {
        $objResponse = new xajaxResponse();
        
        if ($storename_name != '0')
        {
            $output = $this->build_store_number_dropdownlist($storename_name, '0');
            $objResponse->Assign("div_store_number", "innerHTML", $output);
        }
        else
        {
            $objResponse->Assign("div_store_number", "innerHTML", "No Numbers Found");
        }
        
        $objResponse->Assign("div_store_upscode", "innerHTML", "");
        
        $objResponse->Assign("txt_result", "innerHTML", "");
        
        return $objResponse;
    }

It builds the SECOND combo box below. Note the onchange item..
Code:
function build_store_number_dropdownlist($storename_name, $store_number)
    {
        $query = $this->store->getStorebyName($storename_name, 'store_number');
        
        $output = "<select id='store_number' name='store_number' size='8' style='width:200px;' ochnge='xajax_store_number_onchange(this[this.selectedIndex].value);'>
// disregard onchange misspelling - had to escape CI filters
        
        //$output .= $this->new_option('Please select a number', '0', $store_number);
        
        foreach ($query as $row)
        {
            $output .= $this->new_option($row['store_number'], $row['store_number'], $store_number);
        }

        $output .= "</select'>";

        return $output;        
    }

I need to pass another parameter ($storename_name) into the onchange request above.

Can I do
Code:
ochnge='xajax_store_number_onchange(this[this.selectedIndex].value,$storename_name);'

... and finally
Code:
function store_number_onchange($store_number, $storename_name)
    {
        ... some functioning code...
    }
#5

[eluser]Colin Williams[/eluser]
EDIT: Disregard earlier reply.

What you want to do should work. Probably not the way I would do it (seems like you are squeezing your process into the one dictated by xajax), but as long as you escape and quote the variable properly, the DOM should have no problem using the information.




Theme © iAndrew 2016 - Forum software by © MyBB