Bonjour à tous,
J'ai un <select> crée en PHP, dans la balise <option> j'ai ajouté un Onclick.
$list_cats[] = "<option onClick=\"remo('$url_de_backlink', '')\" label=\"$path \" value=\"$resultat[id]\">$path</option>";
Dans une autre page quand un membre choisi parmi les catégories celle-ci s'inscrit bien dans un input au dessus, seulement voila si il choisit une autre catégorie celle-ci s'ajoute hors je voudrais qu'elle remplace la première.
Code JAVASCRIPT
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
| <script type="text/javascript">
<!--
function remo(repdeb, repfin) {
var input = document.forms['formulaire'].elements['motifrefus'];
input.focus();
/* pour l'Explorer Internet */
if(typeof document.selection != 'undefined') {
/* Insertion du code de formatage */
var range = document.selection.createRange();
var insText = range.text;
range.text = repdeb + insText + repfin;
/* Ajustement de la position du curseur */
range = document.selection.createRange();
if (insText.length == 0) {
range.move('character', -repfin.length);
} else {
range.moveStart('character', repdeb.length + insText.length + repfin.length);
}
range.select();
}
/* pour navigateurs plus récents basés sur Gecko */
else if(typeof input.selectionStart != 'undefined')
{
/* Insertion du code de formatage */
var start = input.selectionStart;
var end = input.selectionEnd;
var insText = input.value.substring(start, end);
input.value = input.value.substr(0, start) + repdeb + insText + repfin + input.value.substr(end);
/* Ajustement de la position du curseur */
var pos;
if (insText.length == 0) {
pos = start + repdeb.length;
} else {
pos = start + repdeb.length + insText.length + repfin.length;
}
input.selectionStart = pos;
input.selectionEnd = pos;
}
/* pour les autres navigateurs */
else
{
/* requête de la position d'insertion */
var pos;
var re = new RegExp('^[0-9]{0,3}$');
while(!re.test(pos)) {
pos = prompt("Insertion à la position (0.." + input.value.length + "):", "0");
}
if(pos > input.value.length) {
pos = input.value.length;
}
/* Insertion du code de formatage */
var insText = prompt("");
input.value = input.value.substr(0, pos) + repdeb + insText + repfin + input.value.substr(pos);
}
}
//-->
</script> |
Merci d'avance pour votre aide.
Partager