Bonjour,

j'ai un souci pour créer dynamiquement des champs.

avec IE, ça marche nikel mais avec firefox, ça ne marche pas.

Voici le code :

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
72
73
74
75
76
77
78
79
function create_champ(){
n++ ;
	//			for (k=0;k<tab_type.length;k++)
		//			{
			//			option += "<option value='"+tab_idtype[k]+"'>"+tab_type[k]+"</option>" ;
			//		}			
 
if(i<1){
	document.getElementById('surface').innerHTML += "<div id='surf_"+i+"' style='display:block'>"+
	"<table align='center' id='tab_module'>"+
		"<tr>"+
			"<td colspan='2'><strong>Surface n°1</strong></td>"+
		"</tr>"+
		"<tr>"+
			"<td id='title'>Niveau</td>"+
			"<td>"+
				"<input type='text' name='niveau_"+i+"' id='niveau_"+i+"' size='20' onfocus='focus_css(this.id)' onblur='blur_css(this.id)' />"+
			"</td>"+
		"</tr>"+
		"<tr>"+
			"<td id='title'>Description</td>"+
			"<td>"+
				"<textarea name='desc_surf_"+i+"' id='desc_surf_"+i+"' cols='40' rows='3' onfocus='focus_css(this.id)' onblur='blur_css(this.id)'></textarea>"+
			"</td>"+
		"</tr>"+
		"<tr>"+
			"<td id='title'>Type</td>"+
			"<td>"+
				"<input type='text' name='type_surf_"+i+"' id='type_surf_"+i+"' size='20' onfocus='focus_css(this.id)' onblur='blur_css(this.id)'>"+
			"</td>"+
		"</tr>"+
		"<tr>"+
			"<td id='title'>Superficie</td>"+
			"<td>"+
				"<input type='hidden' value='"+n+"' name='nb_surf' id='nb_surf' />"+
				"<input type='text' name='superficie_surf_"+i+"' id='superficie_surf_"+i+"' size='20' onfocus='focus_css(this.id)' onblur='blur_css(this.id)'/>"+
			"</td>"+
		"</tr>"+
	"</table>"+
	"<br></div>";
}
else{
 
	document.getElementById('surface').innerHTML += "<div id='surf_"+i+"' style='display:block'>"+
	"<table align='center' id='tab_module'>"+
		"<tr>"+
			"<td colspan='2'><strong>Surface n°"+n+"</strong></td>"+
		"</tr>"+
		"<tr>"+
			"<td id='title'>Niveau</td>"+
			"<td>"+
				"<input type='text' name='niveau_"+i+"' id='niveau_"+i+"' size='20' onfocus='focus_css(this.id)' onblur='blur_css(this.id)' />"+
			"</td>"+
		"</tr>"+
		"<tr>"+
			"<td id='title'>Description</td>"+
			"<td>"+
				"<textarea name='desc_surf_"+i+"' id='desc_surf_"+i+"' cols='40' rows='3' onfocus='focus_css(this.id)' onblur='blur_css(this.id)'></textarea>"+
			"</td>"+
		"</tr>"+
		"<tr>"+
			"<td id='title'>Type</td>"+
			"<td>"+
				"<input type='text' name='type_surf_"+i+"' id='type_surf_"+i+"' size='20' onfocus='focus_css(this.id)' onblur='blur_css(this.id)'>"+
			"</td>"+
		"</tr>"+
		"<tr>"+
			"<td id='title'>Superficie</td>"+
			"<td>"+
				"<input type='text' name='superficie_surf_"+i+"' id='superficie_surf_"+i+"' size='20' onfocus='focus_css(this.id)' onblur='blur_css(this.id)'/>"+
			"</td>"+
		"</tr>"+
	"</table>"+
	"<input type='hidden' value='"+n+"' name='nb_surf' id='nb_surf' />"+
	"<input type='button' value='Supprimer' class='bouton_fiche' onClick='remove_champ("+i+")' />"+
	"<br></div>";
}
i++;
}
Je crée une fois l'element, je remplis les champs et quand je veux ajouter un nouvel element, les champs du premier element se vide.

Pourriez vous m'aider ?

Merci

Sylvain