ChaN
初級專家
1563 466
4688 1023
假設前面表單傳來了
<input name="id" type="hidden" value="1" />
<input name="id" type="hidden" value="1" />
<input name="id" type="hidden" value="2" />
<input name="id" type="hidden" value="3" />
<input name="id" type="hidden" value="3" />
<input name="id" type="hidden" value="2" />
<input name="id" type="hidden" value="3" />
接收端這邊怎麼下可以得出
id = 1 amount: 2
id = 2 amount: 2
id = 3 amount: 3
<pre class="c" name="code">
ReDim C(3)
for each item in Request("id")
C(item) = C(item) + 1
next
for each x in C
Response.Write "id=" & x & ",amount:" & C(x)
next
最後這樣搞定
<pre class="c" name="code">
Dim ValName, ValSection, d
Set d = Server.CreateObject("Scripting.Dictionary")
ValName = Split(Request("visitor_name"), ",")
ValSection = Split(Request("visitor_section"), ",")
For I = 0 To Ubound(ValName)
Section = Trim(ValSection(I))
If d.Exists(Section) Then
n = d.Item(Section)
n = n + 1
d.Item(Section) = n
Else
d.Add Section, 1
End If
Next
dk = d.keys
di = d.items
For J = 0 To d.Count-1
Response.Write(dk(J)&"共有"&di(J)&"個<br />")
Next