程式如下
我只取其中重點)
==================================
<html>
<body>
<form runat="server">
<table width="60%" align="center">
<tr>
<td valign="top">興趣:</td>
<td><asp:listbox runat="server" id="love" Selectionmode="multiple">
<asp:listitem>運動</asp:listitem>
<asp:listitem>電影</asp:listitem>
<asp:listitem>閱讀</asp:listitem>
<asp:listitem>音樂</asp:listitem>
<asp:listitem>看海</asp:listitem>
<asp:listitem>歌唱</asp:listitem>
</asp:listbox>
</td>
</tr>
<asp:button runat="server" text="傳送" onclick="button_click" />
</form>
</body>
</html>
<script language="vb" runat="server">
Sub button_click(sender As object,e As Eventargs)
Dim i
Dim url
Dim loveurl
url="ok2.aspx?"
url &= "&name=" & name.text
url &= "&sex=" & sex.selecteditem.text
url &= "&shit=" & shit.selecteditem.text
url &= "&mary=" & mary.selecteditem.text
url &= "&tel=" & tel.text
url &= "&home=" & home.text
For i=0 To love.items.count-1
If love.items(i).selected Then
loveurl &=love.items(i).text & "<br>"
end If
Next
url &= "&love=" & loveurl
server.transfer(url)
End sub
</script>
==============
當然,此程式按下傳送會跳至令一個網頁,另一網頁就略過.
問題如下:
loveurl &=love.items(i).text & "<br>" 此行
(i)為何要加 & 這裡不太懂????
(ii)另外若我把副程式改成以下:
也可以,不過原本應該能複選並顯示出複選出的資料,卻只能顯示出一項,why?????
<script language="vb" runat="server">
Sub button_click(sender As object,e As Eventargs)
Dim i
Dim url
url="ok2.aspx?"
url &= "&name=" & name.text
url &= "&sex=" & sex.selecteditem.text
url &= "&shit=" & shit.selecteditem.text
url &= "&mary=" & mary.selecteditem.text
url &= "&tel=" & tel.text
url &= "&home=" & home.text
For i=0 To love.items.count-1
If love.items(i).selected Then
love.selecteditem.text=love.items(i).text & "<br>"
^^^^^^^^^^^^^^
end If
Next
url &= "&love=" & love.selecteditem.text
server.transfer(url) ^^^^^^^^^^^^^^
End sub
</script>
以上(i)(ii)兩個問題,謝謝各位高手的解答.......
此主題經由不飛轉移!