AnakinVB
07-29-2002, 09:51 AM
Hello,
All I am trying to do is populate one-line text box from a selection box, upon clicking.
It is easy in VB6:
------------------------------------------
For j = 0 To List1.ListCount - 1
If List1.Selected(j) = True Then
txtItems.Text = CStr(List1.List(j))
End If
Next
End Sub
----------------------------------------------------
But it seems really tricky in ASP/VBScript.
1) If Rezner reads this, the javascript template you gave me:
onClick="yourFormName.yourTextbox.value=yourFormName.yourCombo.value";
calls for the form name, but when we created the controls we omitted the form tags altogether. How do I handle the form name when there isn't a form tag?
2) I have tried to integrate Javascript in the middle of ths page. the <%Language=JavaScript%>
How and when will the interpreter know to switch back to VB Script?
3) Here is my failed attempt:
--------------------------
<%
Set AnakinadoCon = Server.CreateObject("ADODB.Connection")
AnakinadoCon.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & Server.MapPath("AnakinCars.mdb") & ";" & _
"PeRSist Security Info=False"
Set RS = Server.CreateObject("ADODB.Recordset")
RS.Open "SELECT carID, carName " & _
"FROM Cars ORDER BY carName", _
AnakinadoCon, 3, 3, 1
response.write "<SELECT" & "NAME =" & "AnakinCombo>"
While NOT RS.EOF
response.write _
"<OPTION VALUE=" & RS("carID") & ">" & RS("carName") & "</OPTION>"
onClick="AnakinText.value=AnakinCombo.value";
RS.Movenext
Wend
response.write "</SELECT>"
%>
<INPUT NAME = "AnakinText">
<%
While Not RS.EOF
RS.MoveNext
Wend
%>
</SELECT>
<%
'Close and destroy ADODB Recordset object
RS.Close
Set RS = Nothing
'Close and destroy ADODB Connection object
AnakinadoCon.Close
Set AnakinadoCon = Nothing
%>
----------------------------------
thx,
Jason
All I am trying to do is populate one-line text box from a selection box, upon clicking.
It is easy in VB6:
------------------------------------------
For j = 0 To List1.ListCount - 1
If List1.Selected(j) = True Then
txtItems.Text = CStr(List1.List(j))
End If
Next
End Sub
----------------------------------------------------
But it seems really tricky in ASP/VBScript.
1) If Rezner reads this, the javascript template you gave me:
onClick="yourFormName.yourTextbox.value=yourFormName.yourCombo.value";
calls for the form name, but when we created the controls we omitted the form tags altogether. How do I handle the form name when there isn't a form tag?
2) I have tried to integrate Javascript in the middle of ths page. the <%Language=JavaScript%>
How and when will the interpreter know to switch back to VB Script?
3) Here is my failed attempt:
--------------------------
<%
Set AnakinadoCon = Server.CreateObject("ADODB.Connection")
AnakinadoCon.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & Server.MapPath("AnakinCars.mdb") & ";" & _
"PeRSist Security Info=False"
Set RS = Server.CreateObject("ADODB.Recordset")
RS.Open "SELECT carID, carName " & _
"FROM Cars ORDER BY carName", _
AnakinadoCon, 3, 3, 1
response.write "<SELECT" & "NAME =" & "AnakinCombo>"
While NOT RS.EOF
response.write _
"<OPTION VALUE=" & RS("carID") & ">" & RS("carName") & "</OPTION>"
onClick="AnakinText.value=AnakinCombo.value";
RS.Movenext
Wend
response.write "</SELECT>"
%>
<INPUT NAME = "AnakinText">
<%
While Not RS.EOF
RS.MoveNext
Wend
%>
</SELECT>
<%
'Close and destroy ADODB Recordset object
RS.Close
Set RS = Nothing
'Close and destroy ADODB Connection object
AnakinadoCon.Close
Set AnakinadoCon = Nothing
%>
----------------------------------
thx,
Jason