All pastes #243433 Raw Edit

Quelque chose

public text v1 · immutable
·published 2006-11-08 13:59 UTC
rendered paste body
<script language="javascript" type="text/javascript">
  var store = new Array();
  
  //store[0] = new Array();
  store[1] = new Array(<?php echo return_array_JS_taches(); ?>);
  store[2] = new Array(<?php echo return_array_JS_agences(); ?>);
  store[3] = new Array(<?php echo return_array_JS_particuliers(); ?>);
  store[4] = new Array(<?php echo return_array_js_prospects(); ?>);
  store[5] = new Array(<?php echo return_array_JS_users(); ?>);
  store[6] = new Array(<?php echo return_array_JS_fournisseurs(); ?>);

function init_dest(formul, firBox, secBox) {
  if(formul.elements[firbox].options[i] == 0) {
    optionTest = true;
    lgth = formul.elements[secBox].options.length;
    formul.elements[secBox].options[lgth] = null;
    if(formul.elements[secBox].options[lgth]) optionTest = false;
  } else {
    populate_dest(formul, elements[firBox], elements[secBox]);
  }
}

function populate_dest(formul, firBox, secBox) {
  if (!optionTest) return;
  var box = formul.elements[firBox];
  var number = box.options[box.selectedIndex].value;
  if (!number) return;
  var list = store[number];
  var box2 = formul.elements[secBox];
  box2.options.length = 0;
  for(i=0;i<list.length;i+=2) {
    box2.options[i/2] = new Option(list[i],list[i+1]);
  }
}
</script>

<?php
$req = 'SELECT id_type_rdv, libelle';
$req .= ' FROM types_rdv';
$req .= ' ORDER BY libelle ASC';

$i = 0;
connec();
$exe = mysql_query($req) or die($req);
mysql_close();

$destinataire = '<select name="id_type_rdv" onChange="populate_dest(document.forms[\'rendez_vous\'], \'id_type_rdv\', \'id_dest\')" style="width:150px;">';
$destinataire .= '<option>Destinataire</option>';
while($res = mysql_fetch_assoc($exe)) {
  if($res['id_type_rdv'] == $id_type_rdv) { $sel = 'selected="selected"'; }
  else { $sel = ''; }
  $destinataire .= '<option value="'.$res['id_type_rdv'].'" '.$sel.'>'.$res['libelle'].'</option>';
}
$destinataire .= '</select>';
?>
<form name="rendez_vous" action="<?php echo $form; ?>" method="post"><fieldset>
<label>Destinataire :</label>
<?php echo $destinataire; ?>
<select name="id_dest" style="width:198px;"></select><br/>
</fieldset></form>