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
| <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>script temporaire</title>
<meta http-equiv="Content-type" content="text/html; charset=UTF-8" />
<style type="text/css">
* {margin:0;padding:0;}
body {margin:10px;background:#000;color:#ddd;font-size:1em;font-family:Helvetica, Arial, sans-serif;}
h1 {font-size:1.5em;}
ul {margin:0 0 5px;background:#333;}
li {margin:0 0 0 5px;list-style-position:inside;}
</style>
</head>
<body>
<script type="text/javascript">
user1 = {};
user1.nom = "DUPONT";
user1.prenom = "Jean";
user2 = {};
user2.nom = "DURAND";
user2.prenom = "Paul";
userArray={
setUser: function(nr,user){nr=nr.toString();userArray[nr]=user},
callUser: function(nr){ alert(nr);
return (userArray[nr])?userArray[nr]:-1}
}
userArray.setUser("a",user1);
userArray.setUser("b",user2);
idUser= "a"
alert(userArray.callUser("a").nom)
idUser= "b"
alert(userArray.callUser("b").nom)
</script>
</body>
</html> |