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
| <!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>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Mes tags</title>
<script type="text/javascript">
var nb_tags = 0; // compteur
function AjouterTag(){
var tag = document.getElementById('ContentTagOeil').value;
if (tag.length<=1) { alert("Vous devriez remplir ce champs avec un terme de plus de une lettre");document.getElementById('ContentTagOeil').focus(); }
else {
var new_span = document.createElement('span'); // on crée un nouvel élément HTML
new_span.id = 'tag' + nb_tags; // on lui donne un identifiant
new_span.innerHTML = tag; // on insère le 'tag'
new_span.innerHTML += '<input type="text" name="titi_' + nb_tags +'"/>'; // on insère le 'tag'
new_span.innerHTML += '<input type="hidden" name="titi_' + nb_tags +'"/>'; // on insère le 'tag'
new_span.innerHTML += ' (<a href="javascript:SupprimerTag(\'tag' + nb_tags + '\')">Supprimer</a>)<br> '; // on complète avec le lien pour retirer le tag
document.getElementById('wrap').appendChild(new_span); // on insère l'objet
nb_tags++; // on incrémente le compteur
}
return false;
}
function SupprimerTag(new_span){
var node=document.getElementById(new_span);
node.parentNode.removeChild(node);
}
</script>
</head>
<body>
<form action="toto.php" name="FormTag" id="FormTag" method="post">
<fieldset>
<select name="produit" id="ContentTagOeil">
<option value="4655">Thé Aromatisé</option>
<option value="7112">Lipton Tea</option>
<option value="9554">Pâté De Volaille</option>
<option value="5314">Arôme Basquaise</option>
<option value="8132">Poule Vermicelle</option>
<option value="11245">Bouillon De Volaille</option>
</select>
<a href="#" title="Ajouter ce tag" onclick="AjouterTag();return false;">Ajouter ce tag</a>
<div id="wrap"><!-- VOICI LE WRAP UTILISE POUR INSERER LES TAGS --></div>
</fieldset>
<input type="submit" name="Submit" value="Envoyer" />
</form>
</body>
</html> |
Partager