bonjour
ayant pas de connaissance en javascript, j'aimerai savoir si c'est possible ?
je voudrais ajouter dans un textaera des photos dont l'utilisateur choisi si écrit a droite gauche....
actuellement on peut mettre jusqu'a 20 photos....j'aimerais avoir que les photos et ouvrir une boite de dialogue pour choisir la position...à la place d'avoir 60 select, il y aura que 20 déjà plus propre.
Code php : Sélectionner tout - Visualiser dans une fenêtre à part
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
			<select onchange="insertTag('&lt;image valeur=&quot;' + this.options[this.selectedIndex].value + '&quot;&gt;', '&lt;/image&gt;', 'textarea');">
			<option value="" class="selected" selected="selected">Choix Photo</option>
	<?php
	// recup foto
	$rec_foto = $bdd->query("SELECT * FROM photos WHERE user = '$log'");
    $rec_fotos = $rec_foto->fetch();
 
	$id_categ = $rec_fotos['id'];
	$nom_categ = $rec_catego['categ'];
	$nom_sous_categ = $rec_catego['sous_categ'];
 
	if ($rec_fotos['photo1'] != '')
    {
    ?>
	<option value="photo1c" >Photo 1 Centré</option>
	<option value="photo1d" >Photo 1 à Droite</option>
	<option value="photo1g" >Photo 1 à Gauche</option>
	<?php
	}
	if ($rec_fotos['photo2'] != '')
    {
    ?>
	<option style="background-color:#eeecec" value="photo2c" >Photo 2 Centré</option>
	<option style="background-color:#eeecec" value="photo2d" >Photo 2 à Droite</option>
	<option style="background-color:#eeecec" value="photo2g" >Photo 2 à Gauche</option>
	<?php
	}
	if ($rec_fotos['photo3'] != '')
    {
    ?>
	<option value="photo3c" >Photo 3 Centré</option>
	<option value="photo3d" >Photo 3 à Droite</option>
	<option value="photo3g" >Photo 3 à Gauche</option>
	<?php
	}
</select>

voila le code javascript mais je ne sais pas comment l'ajouté dans un switch avec du radio
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
 
function insertTag(startTag, endTag, textareaId, tagType) {
	var field = document.getElementById(textareaId);
	var scroll = field.scrollTop;
	field.focus();
 
 
	if (window.ActiveXObject) {
		var textRange = document.selection.createRange();            
		var currentSelection = textRange.text;
	} else {
		var startSelection   = field.value.substring(0, field.selectionStart);
		var currentSelection = field.value.substring(field.selectionStart, field.selectionEnd);
		var endSelection     = field.value.substring(field.selectionEnd);
	}
 
	if (tagType) {
		switch (tagType) {
			case "lien":
					endTag = "</lien>";
					if (currentSelection) {
							if (currentSelection.indexOf("http://") == 0 || currentSelection.indexOf("https://") == 0 || currentSelection.indexOf("ftp://") == 0 || currentSelection.indexOf("www.") == 0) {
									var label = prompt("Quel est le libellé du lien ?") || "";
									startTag = "<lien url=\"" + currentSelection + "\">";
									currentSelection = label;
							} else {
									var URL = prompt("Quelle est l'url ?");
									startTag = "<lien url=\"" + URL + "\">";
							}
					} else {
							var URL = prompt("Quelle est l'url ?") || "";
							var label = prompt("Quel est le libellé du lien ?") || "";
							startTag = "<lien url=\"" + URL + "\">";
							currentSelection = label;                     
					}
			break;
 
			case "citation":
					endTag = "</citation>";
					if (currentSelection) {
							if (currentSelection.length > 30) {
									var auteur = prompt("Quel est l'auteur de la citation ?") || "";
									startTag = "<citation nom=\"" + auteur + "\">";
							} else {
									var citation = prompt("Quelle est la citation ?") || "";
									startTag = "<citation nom=\"" + currentSelection + "\">";
									currentSelection = citation;    
							}
					} else {
							var auteur = prompt("Quel est l'auteur de la citation ?") || "";
							var citation = prompt("Quelle est la citation ?") || "";
							startTag = "<citation nom=\"" + auteur + "\">";
							currentSelection = citation;    
					}
			break;	
		}
	}
 
	if (window.ActiveXObject) {
		textRange.text = startTag + currentSelection + endTag;
		textRange.moveStart('character', -endTag.length-currentSelection.length);
		textRange.moveEnd('character', -endTag.length);
		textRange.select();  
	} else { // Ce n'est pas IE
		field.value = startSelection + startTag + currentSelection + endTag + endSelection;
		field.focus();
		field.setSelectionRange(startSelection.length + startTag.length, startSelection.length + startTag.length + currentSelection.length);
	}  
 
	field.scrollTop = scroll;   
}