Jump to content

ajax chained selects


feri_soft

Recommended Posts

i have this xajax script for chaines selects:

[code]<select id='select1' name='select1' onchange="xajax_chain(this.value)">
<option value="1">1</option>
<option value="2">2</option>
</select>
<?php
function chain($selectValue)
{
    $objResponse = new xajaxResponse();
    $objResponse->addAssign('select2','options.length',0);
  //get values of second select based on first here
    switch($selectValue)
    {
        case '1':
            $objResponse->addScript('addOption("select2","option11");');
            $objResponse->addScript('addOption("select2","option12");');
            break;
        case '2':
            $objResponse->addScript('addOption("select2","option21");');
            $objResponse->addScript('addOption("select2","option22");');
            break;
    }
    return $objResponse;
}
?>[/code]

i could not ake it working can you give me any suggestions?
Link to comment
https://forums.phpfreaks.com/topic/22573-ajax-chained-selects/
Share on other sites

  • 2 weeks later...

Archived

This topic is now archived and is closed to further replies.

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