1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116
| <script type='text/javascript'>
function t(num)
{
for (var i = 1; i <= 5; i++) {
disableInput(("t" + i), (i > num));
}
}
function copieInput(idInputSource, idInputResult, idCheckBox)
{
var inputS = document.getElementById(idInputSource);
var inputR = document.getElementById(idInputResult);
var checkbox = document.getElementById(idCheckBox);
if (checkbox.checked == false) {
disableInput(idInputResult, false);
} else {
disableInput(idInputResult, true);
inputR.value = inputS.value;
}
}
function disableInput(idInput, valeur)
{
var input = document.getElementById(idInput);
input.disabled = valeur;
if (valeur) {
input.style.background = "#CCC";
BSajoute(idInput);
} else {
input.style.background = "#FFF";
BSsuppr(idInput);
}
}
function BSajoute(idInput)
{
for (var i = 0; i < tableauBS.length; i++) {
if (tableauBS[i] == idInput) {
return;
}
}
tableauBS.push(idInput);
}
function BSsuppr(idInput)
{
for (var i = 0; i < tableauBS.length; i++) {
if (tableauBS[i] == idInput) {
alert(idInput + " supprimé à la position " + i + "\n" +tableauBS);
tableauBS.splice(i, 1);
return;
}
}
}
/**
* A appeler dans le onsubmit du form pour que
* les champs puissent transmettre leurs valeurs
*/
function activeBeforeSubmit()
{
while (tableauBS.length > 0) {
var idInput = tableauBS.pop();
var input = document.getElementById(idInput);
input.disabled = false;
}
}
</script>
<fieldset>
<legend>Activer/désactiver un champ en cliquant sur une case à cocher</legend>
<input name="active" id="idactive" onclick="disableInput('ida', this.checked);" type="checkbox" />
<input name="a" id="ida" type="text" />
</fieldset>
<fieldset>
<legend>Choisir le nombre de champs activés
(les champs sont activés du 1er jusqu'à celui en face du bouton radio inclus)</legend>
<table>
<tbody>
<tr>
<td><input name="to" value="1" onclick="t(1);" type="radio"></td>
<td><input name="t1" id="t1" value="aaaaa" type="text"></td>
</tr>
<tr>
<td><input name="to" value="2" onclick="t(2);" type="radio"></td>
<td><input name="t2" id="t2" value="bbbbb" type="text"></td>
</tr>
<tr>
<td><input name="to" value="3" onclick="t(3);" checked="checked" type="radio"></td>
<td><input name="t3" id="t3" value="ccccc" type="text"></td>
</tr>
<tr>
<td><input name="to" value="4" onclick="t(4);" type="radio"></td>
<td><input disabled="disabled" name="t4" id="t4" value="ddddd" type="text"></td>
</tr>
<tr>
<td><input name="to" value="5" onclick="t(5);" type="radio"></td>
<td><input disabled="disabled" name="t5" id="t5" value="eeeee" type="text"></td>
</tr>
</tbody>
</table>
</fieldset>
<fieldset>
<legend>Recopier dans le champ de droite quand la case est cochée</legend>
<input name="s7" id="s7" onkeyup="copieInput('s7', 'r7', 'copie');" type="text" />
<input id="copie" onclick="copieInput('s7', 'r7', 'copie');" type="checkbox" />
<input name="r7" id="r7" type="text" />
</fieldset> |
Partager