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 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146
| <?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr">
<head>
<title>test DOM</title>
<script type='text/javascript'>//<![CDATA[
function clear_element_node(element){
// Suppression des noeuds enfants^^
while (element.firstChild) {
element.removeChild(element.firstChild);
}
}
function start_inscription(){
// recherche du noeud parent
var form = document.getElementById("loggin")
clear_element_node(form);
// création des nouveaux noeuds
var noeud_fieldset = document.createElement("fieldset");
var noeud_legend = document.createElement("legend");
var noeud_p1 = document.createElement("p");
var noeud_label1 = document.createElement("label");
var input1 = document.createElement("input");
var noeud_p2 = document.createElement("p");
var noeud_label2 = document.createElement("label");
var input2 = document.createElement("input");
var noeud_p3 = document.createElement("p");
var button1 = document.createElement("button");
var button2 = document.createElement("button");
// paramétrage des nouveaux noeuds
noeud_fieldset.id = "inscription";
noeud_fieldset.style.display = "inline";
noeud_legend.appendChild(document.createTextNode("Cool!! Je vien de trouver la zone pour m'inscrire"));
noeud_label1.appendChild(document.createTextNode("Nom d'utilisateur : "));
noeud_label2.appendChild(document.createTextNode("Mot de Passe : "));
input1.setAttribute("type","text");//un autre moyen..
input1.id = "user_name";
input1.setAttribute("maxlength","20");
input2.id = "user_pwd";
input2.type = "password";
input2.setAttribute("maxlength","20");
button1.setAttribute("type","submit");
button1.setAttribute("value","inscription");
button1.appendChild(document.createTextNode("Inscription"));
button2.setAttribute("type","reset");
button2.appendChild(document.createTextNode("RaZ"));
// raccord des noeuds
form.appendChild(noeud_fieldset);
noeud_fieldset.appendChild(noeud_legend);
noeud_fieldset.appendChild(noeud_p1);
noeud_p1.appendChild(noeud_label1);
noeud_label1.appendChild(input1);
noeud_fieldset.appendChild(noeud_p2);
noeud_p2.appendChild(noeud_label2);
noeud_label2.appendChild(input2);
noeud_fieldset.appendChild(noeud_p3);
noeud_p3.appendChild(button1);
noeud_p3.appendChild(button2);
}
function start_connection(){
// recherche du noeud parent
var form = document.getElementById("loggin")
clear_element_node(form);
// création des nouveaux noeuds
var noeud_fieldset = document.createElement("fieldset");
var noeud_legend = document.createElement("legend");
var noeud_p1 = document.createElement("p");
var noeud_label1 = document.createElement("label");
var input1 = document.createElement("input");
var noeud_p2 = document.createElement("p");
var noeud_label2 = document.createElement("label");
var input2 = document.createElement("input");
var noeud_p3 = document.createElement("p");
var button1 = document.createElement("button");
var button2 = document.createElement("button");
var button3 = document.createElement("button");
// paramétrage des nouveaux noeuds
noeud_fieldset.id = "connection";
noeud_fieldset.style.display = "inline";
noeud_legend.appendChild(document.createTextNode("Cool!! Je vien de trouver la zone pour me connecter..."));
noeud_label1.appendChild(document.createTextNode("Nom d'utilisateur : "));
noeud_label2.appendChild(document.createTextNode("Mot de Passe : "));
input1.setAttribute("type","text");//un autre moyen..
input1.id = "user_name";
input1.setAttribute("maxlength","20");
input2.id = "user_pwd";
input2.type = "password";
input2.setAttribute("maxlength","20");
button1.setAttribute("type","submit");
button1.setAttribute("value","connection");
button1.appendChild(document.createTextNode("Connection"));
button2.setAttribute("type","reset");
button2.appendChild(document.createTextNode("RaZ"));
button3.setAttribute("type","button");
button3.setAttribute("value","inscription");
button3.setAttribute("onclick","start_inscription();");
button3.appendChild(document.createTextNode("Inscription"));
// raccord des noeuds
form.appendChild(noeud_fieldset);
noeud_fieldset.appendChild(noeud_legend);
noeud_fieldset.appendChild(noeud_p1);
noeud_p1.appendChild(noeud_label1);
noeud_label1.appendChild(input1);
noeud_fieldset.appendChild(noeud_p2);
noeud_p2.appendChild(noeud_label2);
noeud_label2.appendChild(input2);
noeud_fieldset.appendChild(noeud_p3);
noeud_p3.appendChild(button1);
noeud_p3.appendChild(button2);
noeud_p3.appendChild(button3);
}
//]]></script>
</head>
<body onload="start_connection();">
<!-- Plus loin dans le code -->
<form id="loggin" action="/loggin.php" method="post">
</form>
</body>
</html> |
Partager