salut a tous, je veux une fonction qui remplace un caractère ou plusieurs caractères dans plusieur zones de texte,
j'ai trouvé un exemple de la fonction string.substring(from, to), mais il Remplace seulement dans une zone de texte.
voila l'exemple :
et voila les zones de texte contenant les caractéres a remplacer et la cible du resultat de du fonction javascript
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 <!-- TWO STEPS TO INSTALL REPLACE CHARACTERS: 1. Copy the coding into the HEAD of your HTML document 2. Add the last code into the BODY of your HTML document --> <!-- STEP ONE: Paste this code into the HEAD of your HTML document --> <HEAD> <SCRIPT LANGUAGE="JavaScript"> <!-- This script and many more are available free online at --> <!-- The JavaScript Source!! http://javascript.internet.com --> <!-- Begin function replaceChars(entry) { out = "a"; // replace this add = "z"; // with this temp = "" + entry; // temporary holder while (temp.indexOf(out)>-1) { pos= temp.indexOf(out); temp = "" + (temp.substring(0, pos) + add + temp.substring((pos + out.length), temp.length)); } document.subform.text.value = temp; } // End --> </script> </HEAD> <!-- STEP TWO: Copy this code into the BODY of your HTML document --> <BODY> <center> <form name="subform"> <input type=text name=text size=40 value="abcdabcd"><br> <input type=button name=action value="Done!" onClick="replaceChars(document.subform.text.value);"> <!-- Or to make it change when the user clicks the next --> <!-- field, use this instead of the previous two lines: --> <!-- <input type=text name=text size=40 value="abcdabcd" onBlur="replaceChars(this.value);"> --> </form> </center> <p><center> <font face="arial, helvetica" size="-2">Free JavaScripts provided<br> by <a href="http://javascriptsource.com">The JavaScript Source</a></font> </center><p> <!-- Script Size: 1.09 KB -->
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3 for($i=1;$i<=10;$i++) { <input size="70" dir="ltr" name="url'.$i.'" /><br /> }
Partager