Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- How do I get the values of checked checkboxes in a drupal? I'd like to display them in an alert everytime one of the checkboxes is checked. Below is what i am working with:
- $query = db_select('taxonomy_term_data', 't');
- $query
- ->fields('t', array('vid', 'name', 'tid'))
- ->condition('t.vid', 2, '=');
- $result = $query->execute();
- $options = array();
- foreach ($result as $row) {
- $options[$row->tid] = $row->name;
- };
- $form['mouth'] = array(
- '#type' => 'checkboxes',
- '#weight' => '11',
- '#options' => $options,
- '#prefix' => '<div style="background:#FF7F55;">',
- '#suffix' => '</div>',
- '#ajax' => array(
- 'callback' => 'make_topic_chex_callback',
- 'wrapper' => 'gunge',
- 'method' => 'append',
- 'progress' => array('type' => 'none'),
- ),
- );
- function make_topic_chex_callback($form, $form_state) {
- $derps = $form_state['values']['mouth'];
- $commands = array();
- $commands[] = ajax_command_alert("Alert requested at " . $derps);
- return array('#type' => 'ajax', '#commands' => $commands);
- }
- In make_topic_chex_callback , I want to alert the values of the checkboxes in $form['mouth']
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement