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
|
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>test</title>
<style type='text/css'>
textarea { height:100px;
width:80%;
}
</style>
<script type='text.javascript'>
function enrichit(){
var att=new Array()
for (i=0; i<4;i++){
switch (true){
case (document.getElementById("bold").checked && (" "+att.join(" ")+" ").indexOf(' b ')==-1) : att.push("b");
break;
case (document.getElementById("italic").checked && (" "+att.join(" ")+" ").indexOf(' i ')==-1) : att.push("i");
break;
case (document.getElementById("underline").checked && (" "+att.join(" ")+" ").indexOf(' u ')==-1): att.push("u");
break;
case (document.getElementById("greater").checked && (" "+att.join(" ")+" ").indexOf(' big ')==-1): att.push("big");
break;
case (document.getElementById("smaller").checked && (" "+att.join(" ")+" ").indexOf(' small ')==-1): att.push("small")
}
}
var str = ""
for (var i=0; i<att.length; i++) {
str += "<" + att[i] + ">"
}
str += document.getElementById('mazone').value
for (var i=att.length-1; i>-1; i--) {
str += "</" + att[i] + ">"
}
document.getElementById('code').value=str
document.getElementById('resultat').innerHTML=str
}
</script>
</head>
<body>
gras <input type='checkbox' id="bold" /><br/>
italique <input type='checkbox' id="italic"/><br/>
souligné <input type='checkbox' id="underline" /><br/>
grand <input type='checkbox' id="greater"><br/>
petit <input type='checkbox' id="smaller"><br/>
<br/>
<textarea id="mazone" rows="1" cols="20"></textarea>
<input type="button" onclick="enrichit()" value="go" /><br/>
le code:<br/>
<textarea id='code' rows="1" cols="20"></textarea><br/>
le résultat:<br/>
<div id='resultat'></div><br/>
</body>
</html> |