Hi!
I have a Webform in my site and I need to autofill various fields depending on a first field.
In fact, I need to fill several fields depending on the option selected in the first field.
If, for example, you choose the option "2" in the first field, I need to fill in four fields with the option 2 (with their respective options "2").
I've been playing with hooks and I managed to modify the fields.
This is my code:

<?php
       
/*
 * Implementation of hook_form_alter()
 */
function formulario_practicas_form_alter(&$form, &$form_state, $form_id){
  // target a single form
  if($form_id == "webform_client_form_1"){
	$form['submitted']['si_eres_estudiante']['codigo_del_centro']['#value']='1';
	$form['submitted']['si_eres_estudiante']['codigo_de_titulacion']['#value']='1';
  }
}

with this code, the two fields (codigo_del_centro and codigo_de_titulacion) have selected the option "1".
But.......I think I'm missing some conditional!!!

I need that if option 1 is selected in the first field, the second field (and two more) select the same option.
you know, something like "if codigo_del_centro=1 then codigo_de_titulacion =1" but "if codigo_del_centro=2 then codigo_de_titulacion =2" and so on.
is this possible or is it crazy?

many thanks to all of you!