[VBSCRIPT] concaténer 2 noms de variable
bonjour, j'ai un formulaire web que je créé dynamiquement:
Code:
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
|
<table border="0" width="100%">
<%
cpt=1
do while cpt<=50
%>
<tr>
<td valign="top">
<p align="left"><font size="2" face="Verdana">[<%=cpt%>]</font></p>
</td>
<td>
<td valign="top">
<p align="left"><font size="2" face="Verdana">Nom :</font></p>
</td>
<td>
<input type="text" name="NomVisiteur<%=cpt%>" size="40">
</td>
<td valign="top">
<p align="left"><font size="2" face="Verdana">Prénom :</font></p>
</td>
<td>
<input type="text" name="PrenomVisiteur<%=cpt%>" size="40">
</td>
</tr>
<%
cpt = cpt + 1
loop
%>
</table> |
par ex:le nom du champ texte sera de la forme:
NomVisiteur1
NomVisiteur2
NomVisiteur3
...
NomVisiteur50
j'ai donc créé 50 champs texte de nom/prénom...
maintenant je dois les tester en vbscript lors de la validation du formulaire:
le pb : je ne sais pas comment faire pr concaténer le nom du champ pr tester sa valeur...
pr éviter de faire ca :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
|
if (document.all.NomVisteur1.value="") then
...
end if
if (document.all.NomVisteur2.value="") then
...
end if
if (document.all.NomVisteur3.value="") then
...
end if
...
if (document.all.NomVisteur50.value="") then
...
end if |
j'aimerai le rendre dynamique:
genre:
je fais une fonction:
Code:
1 2 3 4 5 6 7 8 9 10 11 12
|
Function checkALLVisiteur()
i=1
do while i<=2
if (document.all.NomVisiteur&i.Value = "") and (document.all.PrenomVisiteur&i.Value = "") then
checkALLVisiteur = False
Else
checkALLVisiteur = true
End if
i = i + 1
loop
end function |
=> en concaténant document.all.NomVisiteuravec le compteur i et finir par .value
Comment faire
j'ai deja fait ce genre de chose en php...
mais en vbscript...