0

enter image description here

Above is the sample screenshot of my form where I would like to do is:

When I click/check on radio button "One" then its value should display in textfield of "Display".

Code:

function test_radio_menu() {
  $items['test_radio'] = array(
    'title' => 'test_radio',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('test_radio_form'),
    'access arguments' => array('access content'),
    'access callback' => TRUE,
    );
  return $items;
}

/**
* Implements hook_form().
*/

function test_radio_form($form, &$form_submit){

/* the options to display in our form radio buttons */
$options = array(
  'one' => t('One'),
   'two' => t('Two'),
);

$form['count'] = array(
  '#title' => t('Count'),
  '#type' => 'radios',
  '#options' => $options,

);

$form['display'] = array(
'#title' => t('Display'),
'#type' => 'textfield',
'#value' => ,
  );

$form['submit'] = array(
'#value' => t('PROCEED'),
'#type' => 'submit',
  );

return $form;
}
1

You should use drupal ajax form try this code

function test_radio_form($form, &$form_submit){

/* the options to display in our form radio buttons */
$options = array(
  'one' => t('One'),
   'two' => t('Two'),
);

$form['count'] = array(
  '#title' => t('Count'),
  '#type' => 'radios',
  '#options' => $options,
  '#ajax' => array(
            'callback' => 'myid_print_all_submitted_id_callback',
            'wrapper' => 'myid_print_search_idnumber_wrapper',
  ),

);

$form['display'] = array(
'#title' => t('Display'),
'#type' => 'textfield',
'#value' => isset($form_state['values']['count']) ? $form_state['values']['count'] : '',
'#prefix' => '<div id="myid_print_search_idnumber_wrapper">',
'#suffix' => '</div>',
  );

$form['submit'] = array(
'#value' => t('PROCEED'),
'#type' => 'submit',
  );

return $form;
}
function myid_print_all_submitted_id_callback($form, $form_state)
{
      return $form['display'];
}
|improve this answer|||||
0

it should work like this

html :

  <input type="radio" name="mode" id="radio"   class="test1" value="text" onclick="BT('#message')" />

js

function BT (id) {

    $('.Bt')..attr('id', 'your-id-value');

}
|improve this answer|||||
  • hi madman thanks for your reply, but i want to make in drupal 7. – Rahul Baisane Oct 5 '14 at 22:40
  • its jquery you can add it to you template file and see the result its should not make problem . but if the page created by drupal you need to add js to header file then add html in your editor useing html code editor – madman Oct 6 '14 at 12:01
  • -madman- thanks for your suggestion i will try it soon. – Rahul Baisane Oct 6 '14 at 14:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.