Snippets

Create an account or login to be able to add, comment and rate snippets.

Navigation

Snippets tagged "select remote ajax" Snippets tagged "select remote ajax"

Select with a onChange remote function option

If you need to call a remote function with the parameter of the changed select .

Nota for François : Could be cool to have a better documentation of remote_function.

Here is the editSuccess.php

<tr>
  <th>
  <?php echo __('Domains:')  ?>
  </th>
  <td>
  <?php echo form_error('domain') ?>
  <?php echo select_tag('domain', objects_for_select(
           $domains, 'getIdDomain', 'getName',
           $list->getDomain(), 'include_custom='.__('Choose a domain')),
           array(
               'onchange' =>
                 remote_function(array(
                   'update' => 'item_domain',
                   'url' => 'list/subdomain',
                   'with' => "'id=' + this.options[this.selectedIndex].value"
                 ))
           )
           ) ?>
  </td>
</tr>
 
<tr>
  <th>
  <?php echo __('Sub domains:')?>
  </th>
  <td>
  <?php echo form_error('sub_domain') ?>
  <div id="item_domain">
  <?php echo select_tag('sub_domain', objects_for_select(
           $list_sub_domains, 'getIdDomain', 'getName',
           $list->getSubDomain(),
           'include_custom='.__('Choose a sub domain')
           )) ?>
  </div>
  </td>
</tr>

Here is the subdomainSuccess.php

<?php use_helper('Object') ?>
 
<?php echo select_tag('sub_domain', objects_for_select(
           $list_sub_domains, 'getIdDomain', 'getName',
           0, 'include_custom='.__('Choose a sub domain')
           )) ?>
by mlier on 2007-03-24, tagged ajax  remote  select 
(1 comment)