Click to See Complete Forum and Search --> : populating a dropdown list based on the value of a textbox
joelo
11-17-2003, 04:03 AM
I want to automatically populate my dropdown list related data based on the data in a textbox on form.
My database has a table with two columns [wellid] and [welljacketID]
ie: wellID welljacketID
1 WJ1
1D WJ1
2 WJ1
2D WJ1
4 WJ3
4D WJ3
5 WJ3
5D WJ3
so now...based on which of the welljacketIDs in my Texbox onLoad....wellid dropdown will be populated with related wellids
ie
when the value of my textbox(welljacketid) is WJ1 onLoad of my FORM, my dropdown list will be populated with
1
1D
2
2D
when the value of my textbox(welljacketid) is WJ3 onLoad of my FORM, my dropdown list will be populated with
4
4D
5
5D
This is my complete code:
<%
Response.expires = 0
Response.expiresabsolute = Now() - 1
Response.addHeader "pragma", "no-cache"
Response.addHeader "cache-control", "private"
Response.CacheControl = "no-cache"
%>
<!--#include file="db.asp"-->
<!--#include file="aspmkrfn.asp"-->
<%
Response.Buffer = True
key = Request.Querystring("key")
If key="" OR IsNull(key) Then key = Request.Form("key")
If key="" OR IsNull(key) Then Response.Redirect "welljacketdatabaselist.asp"
'get action
a=Request.Form("a")
If a="" OR IsNull(a) Then
a="I" 'display with input box
End If
'get fields from form
x_WELLJACKETID = Request.Form("x_WELLJACKETID")
x_WELLID = Request.Form("x_WELLID")
' Open Connection to the database
Set conn = Server.CreateObject("ADODB.Connection")
conn.Open xDb_Conn_Str
Select Case a
Case "I": ' Get a record to display
tkey = "" & key & ""
strsql = "SELECT * FROM [welljacketdatabase] WHERE [ID]=" & tkey
Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open strsql, conn
If rs.EOF Then
Response.Clear
Response.Redirect "welljacketdatabaselist.asp"
Else
rs.MoveFirst
End If
' Get the field contents
x_WELLJACKETID = rs("WELLJACKETID")
x_WELLID = rs("WELLID")
rs.Close
Set rs = Nothing
Case "U": ' Update
' Open record
tkey = "" & key & ""
strsql = "SELECT * FROM [welljacketdatabase] WHERE [ID]=" & tkey
Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open strsql, conn, 1, 2
If rs.EOF Then
Response.Clear
Response.Redirect "welljacketdatabaselist.asp"
End If
tmpFld = Trim(x_WELLJACKETID)
If trim(tmpFld) & "x" = "x" Then tmpFld = Null
rs("WELLJACKETID") = tmpFld
tmpFld = Trim(x_WELLID)
If trim(tmpFld) & "x" = "x" Then tmpFld = Null
rs("WELLID") = tmpFld
rs.Update
rs.Close
Set rs = Nothing
conn.Close
Set conn = Nothing
Response.Clear
Response.Redirect "welljacketdatabaselist.asp"
End Select
%>
<form onSubmit="return EW_checkMyForm(this);" action="welljacketdatabaseadd.asp" method="post">
<p>
<input type="hidden" name="a" value="A">
<table border="0" cellspacing="1" cellpadding="5" bgcolor="#CCCCCC">
<tr>
<td bgcolor="#0099CC"><font color="#FFFFFF"><font size="-1">WELLJACKETID</font> </font></td>
<td bgcolor="#F5F5F5"><font size="-1"><input type="text" name="x_WELLJACKETID" size=30 maxlength=50 value="<%= Server.HtmlEncode(x_WELLJACKETID&"") %>"></font> </td>
</tr>
' My dropdown List starts Here********************
<tr>
<td bgcolor="#0099CC"><font color="#FFFFFF"><font size="-1">WELLID</font> </font></td>
<td bgcolor="#F5F5F5"><font size="-1"><%
x_WELLIDList = "<SELECT name='x_WELLID'><OPTION value=''>Please Select</OPTION>"
sqlwrk = "SELECT [WELLID] FROM [wellheaddatabase]"
Set rswrk = Server.CreateObject("ADODB.Recordset")
rswrk.Open sqlwrk, conn, 1, 2
If Not rswrk.EOF Then
datawrk = rswrk.GetRows
rowswrk = UBound(datawrk, 2)
For rowcntwrk = 0 To rowswrk
x_WELLIDList = x_WELLIDList & "<OPTION value='" & datawrk(0, rowcntwrk) & "'"
If cstr(datawrk(0, rowcntwrk)&"") = cstr(x_WELLID&"") Then
x_WELLIDList = x_WELLIDList & " selected"
End If
x_WELLIDList = x_WELLIDList & ">" & datawrk(0, rowcntwrk) & "</option>"
Next
End If
rswrk.Close
Set rswrk = Nothing
x_WELLIDList = x_WELLIDList & "</SELECT>"
response.write x_WELLIDList
%>
</font> </td>
</tr>
</table>
<p>
<input type="submit" name="Action" value="ADD">
</form>
simflex
11-17-2003, 07:58 AM
first, what error / problem are you having?
Your code seems to be doing something different from what you are trying to accomplish.
joelo
11-17-2003, 08:33 AM
I don't have an error right now ......Just that I want it to do what had explained....and I don't know how to do it
Please help me out.
Thanks in advance
joelo
11-17-2003, 02:16 PM
I 've tried reopening recordset to use the form field as filter and nothing seem to be happening
This is my complete code:
<%
Response.expires = 0
Response.expiresabsolute = Now() - 1
Response.addHeader "pragma", "no-cache"
Response.addHeader "cache-control", "private"
Response.CacheControl = "no-cache"
%>
<!--#include file="db.asp"-->
<!--#include file="aspmkrfn.asp"-->
<%
Response.Buffer = True
key = Request.Querystring("key")
If key="" OR IsNull(key) Then key = Request.Form("key")
If key="" OR IsNull(key) Then Response.Redirect "welljacketdatabaselist.asp"
'get action
a=Request.Form("a")
If a="" OR IsNull(a) Then
a="I" 'display with input box
End If
'get fields from form
x_WELLJACKETID = Request.Form("x_WELLJACKETID")
x_WELLID = Request.Form("x_WELLID")
' Open Connection to the database
Set conn = Server.CreateObject("ADODB.Connection")
conn.Open xDb_Conn_Str
Select Case a
Case "I": ' Get a record to display
tkey = "" & key & ""
strsql = "SELECT * FROM [welljacketdatabase] WHERE [ID]=" & tkey
Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open strsql, conn
If rs.EOF Then
Response.Clear
Response.Redirect "welljacketdatabaselist.asp"
Else
rs.MoveFirst
End If
' Get the field contents
x_WELLJACKETID = rs("WELLJACKETID")
x_WELLID = rs("WELLID")
rs.Close
Set rs = Nothing
Case "U": ' Update
' Open record
tkey = "" & key & ""
strsql = "SELECT * FROM [welljacketdatabase] WHERE [ID]=" & tkey
Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open strsql, conn, 1, 2
If rs.EOF Then
Response.Clear
Response.Redirect "welljacketdatabaselist.asp"
End If
tmpFld = Trim(x_WELLJACKETID)
If trim(tmpFld) & "x" = "x" Then tmpFld = Null
rs("WELLJACKETID") = tmpFld
tmpFld = Trim(x_WELLID)
If trim(tmpFld) & "x" = "x" Then tmpFld = Null
rs("WELLID") = tmpFld
rs.Update
rs.Close
Set rs = Nothing
conn.Close
Set conn = Nothing
Response.Clear
Response.Redirect "welljacketdatabaselist.asp"
End Select
%>
<form onSubmit="return EW_checkMyForm(this);" action="welljacketdatabaseadd.asp" method="post">
<p>
<input type="hidden" name="a" value="A">
<table border="0" cellspacing="1" cellpadding="5" bgcolor="#CCCCCC">
<tr>
<td bgcolor="#0099CC"><font color="#FFFFFF"><font size="-1">WELLJACKETID</font> </font></td>
<td bgcolor="#F5F5F5"><font size="-1"><input type="text" name="x_WELLJACKETID" size=30 maxlength=50 value="<%= Server.HtmlEncode(x_WELLJACKETID&"") %>"></font> </td>
</tr>
' My dropdown List starts Here********************
<tr>
<td bgcolor="#0099CC"><font color="#FFFFFF"><font size="-1">WELLID</font> </font></td>
<td bgcolor="#F5F5F5"><font size="-1"><%
Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open strsql, conn
x_WELLJACKETID = rs("WELLJACKETID")
x_WELLJACKETID = Request.Form("x_WELLJACKETID")
x_WELLIDList = "<SELECT name='x_WELLID'><OPTION value=''>Please Select</OPTION>"
sqlwrk = "SELECT [WELLID] FROM [wellheaddatabase] WELLJACKETID ='" & Request.Form("x_WELLJACKETID")&"'"
Set rswrk = Server.CreateObject("ADODB.Recordset")
rswrk.Open sqlwrk, conn, 1, 2
If Not rswrk.EOF Then
datawrk = rswrk.GetRows
rowswrk = UBound(datawrk, 2)
For rowcntwrk = 0 To rowswrk
x_WELLIDList = x_WELLIDList & "<OPTION value='" & datawrk(0, rowcntwrk) & "'"
If cstr(datawrk(0, rowcntwrk)&"") = cstr(x_WELLID&"") Then
x_WELLIDList = x_WELLIDList & " selected"
End If
x_WELLIDList = x_WELLIDList & ">" & datawrk(0, rowcntwrk) & "</option>"
Next
End If
rswrk.Close
Set rswrk = Nothing
x_WELLIDList = x_WELLIDList & "</SELECT>"
response.write x_WELLIDList
%>
</font> </td>
</tr>
</table>
<p>
<input type="submit" name="Action" value="ADD">
</form>
joelo
11-18-2003, 08:12 AM
Please all I am trying do is ......a Dependent dropdown box...
Populating itself with datas related to the value of my textbox (x_welljacketID) when the form is opened by the user.
This what I have so far... please help me out:
<form onSubmit="return EW_checkMyForm(this);" action="welljacketdatabaseedit.asp" method="post">
<p>
<input type="hidden" name="a" value="U">
<input type="hidden" name="key" value="<%= key %>">
<table border="0" cellspacing="1" cellpadding="5" bgcolor="#CCCCCC">
<tr>
<td bgcolor="#0099CC"><font color="#FFFFFF"><font size="-1">WELLJACKETID</font> </font></td>
<td bgcolor="#F5F5F5"><font size="-1"><input type="text" name="x_WELLJACKETID" size=30 maxlength=50 value="<%= Server.HtmlEncode(x_WELLJACKETID&"") %>"></font> </td>
</tr>
<tr>
<td bgcolor="#0099CC"><font color="#FFFFFF"><font size="-1">WELLID</font> </font></td>
<td bgcolor="#F5F5F5"><font size="-1"><%
strsql = "SELECT * FROM [welljacketdatabase]"
Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open strsql, conn
x_WELLJACKETID = rs("WELLJACKETID")
x_WELLIDList = "<SELECT name='x_WELLID'><OPTION value=''>Please Select</OPTION>"
sqlwrk = "SELECT [WELLID] "
sqlwrk = sqlwrk & "FROM [wellheaddatabase] "
sqlwrk = sqlwrk & "WHERE (1=1) "
If x_WELLJACKETID <> "" Then
sqlwrk = sqlwrk & "AND WELLJACKETID ='"&X_WELLJACKETID&"'"
End If
sqlwrk = sqlwrk & "ORDER BY [WELLID]"
Set rswrk = Server.CreateObject("ADODB.Recordset")
rswrk.Open sqlwrk, conn, 1, 2
If Not rswrk.EOF Then
datawrk = rswrk.GetRows
rowswrk = UBound(datawrk, 2)
For rowcntwrk = 0 To rowswrk
x_WELLIDList = x_WELLIDList & "<OPTION value='" & datawrk(0, rowcntwrk) & "'"
If cstr(datawrk(0, rowcntwrk)&"") = cstr(x_WELLID&"") Then
x_WELLIDList = x_WELLIDList & " selected"
End If
x_WELLIDList = x_WELLIDList & ">" & datawrk(0, rowcntwrk) & "</option>"
Next
End If
rswrk.Close
Set rswrk = Nothing
x_WELLIDList = x_WELLIDList & "</SELECT>"
response.write x_WELLIDList
%>
</font> </td>
</tr>
<tr>
<td bgcolor="#0099CC"><font color="#FFFFFF"><font size="-1">SDVTime</font> </font></td>
<td bgcolor="#F5F5F5"><font size="-1"><input type="text" name="x_SDVTime" size=30 maxlength=50 value="<%= Server.HtmlEncode(x_SDVTime&"") %>"></font> </td>
</tr>
<tr>
<td bgcolor="#0099CC"><font color="#FFFFFF"><font size="-1">SSVTime</font> </font></td>
<td bgcolor="#F5F5F5"><font size="-1"><input type="text" name="x_SSVTime" size=30 maxlength=50 value="<%= Server.HtmlEncode(x_SSVTime&"") %>"></font> </td>
</tr>
<tr>
<td bgcolor="#0099CC"><font color="#FFFFFF"><font size="-1">SCSSVTime</font> </font></td>
<td bgcolor="#F5F5F5"><font size="-1"><input type="text" name="x_SCSSVTime" size=30 maxlength=50 value="<%= Server.HtmlEncode(x_SCSSVTime&"") %>"></font> </td>
</tr>
<tr>
<td bgcolor="#0099CC"><font color="#FFFFFF"><font size="-1">PANELSUPPLYPRESSURE</font> </font></td>
<td bgcolor="#F5F5F5"><font size="-1"><input type="text" name="x_PANELSUPPLYPRESSURE" size=30 maxlength=50 value="<%= Server.HtmlEncode(x_PANELSUPPLYPRESSURE&"") %>"></font> </td>
</tr>
<tr>
<td bgcolor="#0099CC"><font color="#FFFFFF"><font size="-1">SCSSVHOLDINGPRESSURE</font> </font></td>
<td bgcolor="#F5F5F5"><font size="-1"><input type="text" name="x_SCSSVHOLDINGPRESSURE" size=30 maxlength=50 value="<%= Server.HtmlEncode(x_SCSSVHOLDINGPRESSURE&"") %>"></font> </td>
</tr>
<tr>
<td bgcolor="#0099CC"><font color="#FFFFFF"><font size="-1">ESDTSEHOLDINGPRESSURE</font> </font></td>
<td bgcolor="#F5F5F5"><font size="-1"><input type="text" name="x_ESDTSEHOLDINGPRESSURE" size=30 maxlength=50 value="<%= Server.HtmlEncode(x_ESDTSEHOLDINGPRESSURE&"") %>"></font> </td>
</tr>
<tr>
<td bgcolor="#0099CC"><font color="#FFFFFF"><font size="-1">DIDESDTRIPINDICATORTURNREDDURINGTEST</font> </font></td>
<td bgcolor="#F5F5F5"><font size="-1"><input type="text" name="x_DIDESDTRIPINDICATORTURNREDDURINGTEST" size=30 maxlength=50 value="<%= Server.HtmlEncode(x_DIDESDTRIPINDICATORTURNREDDURINGTEST&"") %>"></font> </td>
</tr>
<tr>
<td bgcolor="#0099CC"><font color="#FFFFFF"><font size="-1">DIDRESETRELAYTRIPDURINGTEST</font> </font></td>
<td bgcolor="#F5F5F5"><font size="-1"><input type="text" name="x_DIDRESETRELAYTRIPDURINGTEST" size=30 maxlength=50 value="<%= Server.HtmlEncode(x_DIDRESETRELAYTRIPDURINGTEST&"") %>"></font> </td>
</tr>
<tr>
<td bgcolor="#0099CC"><font color="#FFFFFF"><font size="-1">WASTSETESTEDDURINGTEST</font> </font></td>
<td bgcolor="#F5F5F5"><font size="-1"><input type="text" name="x_WASTSETESTEDDURINGTEST" size=30 maxlength=50 value="<%= Server.HtmlEncode(x_WASTSETESTEDDURINGTEST&"") %>"></font> </td>
</tr>
<tr>
<td bgcolor="#0099CC"><font color="#FFFFFF"><font size="-1">ISAGASCONDITIONINGSKIDINSTALLED</font> </font></td>
<td bgcolor="#F5F5F5"><font size="-1"><input type="text" name="x_ISAGASCONDITIONINGSKIDINSTALLED" size=30 maxlength=50 value="<%= Server.HtmlEncode(x_ISAGASCONDITIONINGSKIDINSTALLED&"") %>"></font> </td>
</tr>
<tr>
<td bgcolor="#0099CC"><font color="#FFFFFF"><font size="-1">AREPANELFACEGUAGESINTHECORRECTRANGEANDFUNCTIONING</font> </font></td>
<td bgcolor="#F5F5F5"><font size="-1"><input type="text" name="x_AREPANELFACEGUAGESINTHECORRECTRANGEANDFUNCTIONING" size=30 maxlength=50 value="<%= Server.HtmlEncode(x_AREPANELFACEGUAGESINTHECORRECTRANGEANDFUNCTIONING&"") %>"></font> </td>
</tr>
<tr>
<td bgcolor="#0099CC"><font color="#FFFFFF"><font size="-1">OPENANDINSPECTWELLCONTROLPANEL</font> </font></td>
<td bgcolor="#F5F5F5"><font size="-1"><input type="text" name="x_OPENANDINSPECTWELLCONTROLPANEL" size=30 maxlength=50 value="<%= Server.HtmlEncode(x_OPENANDINSPECTWELLCONTROLPANEL&"") %>"></font> </td>
</tr>
<tr>
<td bgcolor="#0099CC"><font color="#FFFFFF"><font size="-1">ISHYDRAULICOILLEVELOK</font> </font></td>
<td bgcolor="#F5F5F5"><font size="-1"><input type="text" name="x_ISHYDRAULICOILLEVELOK" size=30 maxlength=50 value="<%= Server.HtmlEncode(x_ISHYDRAULICOILLEVELOK&"") %>"></font> </td>
</tr>
<tr>
<td bgcolor="#0099CC"><font color="#FFFFFF"><font size="-1">ISCONDITIONOFJACKETANDRISEROK</font> </font></td>
<td bgcolor="#F5F5F5"><font size="-1"><input type="text" name="x_ISCONDITIONOFJACKETANDRISEROK" size=30 maxlength=50 value="<%= Server.HtmlEncode(x_ISCONDITIONOFJACKETANDRISEROK&"") %>"></font> </td>
</tr>
<tr>
<td bgcolor="#0099CC"><font color="#FFFFFF"><font size="-1">ISBOATLOOPINSTALLED</font> </font></td>
<td bgcolor="#F5F5F5"><font size="-1"><input type="text" name="x_ISBOATLOOPINSTALLED" size=30 maxlength=50 value="<%= Server.HtmlEncode(x_ISBOATLOOPINSTALLED&"") %>"></font> </td>
</tr>
<tr>
<td bgcolor="#0099CC"><font color="#FFFFFF"><font size="-1">ESDSTATIONTESTDATE</font> </font></td>
<td bgcolor="#F5F5F5"><font size="-1"><input type="text" name="x_ESDSTATIONTESTDATE" value="<%= Server.HtmlEncode(x_ESDSTATIONTESTDATE&"") %>"></font> </td>
</tr>
<tr>
<td bgcolor="#0099CC"><font color="#FFFFFF"><font size="-1">ESDHELLIPORTTESTDATE</font> </font></td>
<td bgcolor="#F5F5F5"><font size="-1"><input type="text" name="x_ESDHELLIPORTTESTDATE" value="<%= Server.HtmlEncode(x_ESDHELLIPORTTESTDATE&"") %>"></font> </td>
</tr>
<tr>
<td bgcolor="#0099CC"><font color="#FFFFFF"><font size="-1">ESDWELLDECKTESTDATE</font> </font></td>
<td bgcolor="#F5F5F5"><font size="-1"><input type="text" name="x_ESDWELLDECKTESTDATE" value="<%= Server.HtmlEncode(x_ESDWELLDECKTESTDATE&"") %>"></font> </td>
</tr>
<tr>
<td bgcolor="#0099CC"><font color="#FFFFFF"><font size="-1">TESTDATE</font> </font></td>
<td bgcolor="#F5F5F5"><font size="-1"><input type="text" name="x_TESTDATE" value="<%= Server.HtmlEncode(x_TESTDATE&"") %>"></font> </td>
</tr>
<tr>
<td bgcolor="#0099CC"><font color="#FFFFFF"><font size="-1">MONTHYEAR</font> </font></td>
<td bgcolor="#F5F5F5"><font size="-1"><input type="text" name="x_MONTHYEAR" size=30 maxlength=50 value="<%= Server.HtmlEncode(x_MONTHYEAR&"") %>"></font> </td>
</tr>
<tr>
<td bgcolor="#0099CC"><font color="#FFFFFF"><font size="-1">FACILITY</font> </font></td>
<td bgcolor="#F5F5F5"><font size="-1"><input type="text" name="x_FACILITY" size=30 maxlength=50 value="<%= Server.HtmlEncode(x_FACILITY&"") %>"></font> </td>
</tr>
<tr>
<td bgcolor="#0099CC"><font color="#FFFFFF"><font size="-1">AREA</font> </font></td>
<td bgcolor="#F5F5F5"><font size="-1"><input type="text" name="x_AREA" size=30 maxlength=50 value="<%= Server.HtmlEncode(x_AREA&"") %>"></font> </td>
</tr>
<tr>
<td bgcolor="#0099CC"><font color="#FFFFFF"><font size="-1">TECHNICIANSNAME</font> </font></td>
<td bgcolor="#F5F5F5"><font size="-1"><input type="text" name="x_TECHNICIANSNAME" size=30 maxlength=99 value="<%= Server.HtmlEncode(x_TECHNICIANSNAME&"") %>"></font> </td>
</tr>
<tr>
<td bgcolor="#0099CC"><font color="#FFFFFF"><font size="-1">COMMENTS</font> </font></td>
<td bgcolor="#F5F5F5"><font size="-1"><textarea cols=35 rows=4 name="x_COMMENTS"><%= x_COMMENTS %></textarea></font> </td>
</tr>
</table>
<p>
<input type="submit" name="Action" value="EDIT">
</form>
slyfox
11-18-2003, 09:11 AM
is your page actually displaying any data?
is "welljacketdatabase" a table in your database?
also instead of using "=" to append values to your variables, use "+="
joelo
11-18-2003, 10:24 AM
No Is displaying data like I want it to
Yes,... welljacketdatabase is a table in my database
Please seem to understand the part of using "+" to append data
slyfox
11-18-2003, 10:56 AM
sorry...
I see you're using asp - vbscript
use "& ="
eg.
variable = ""
variable & variable = ""
variable & variable = ""
let me know if you still have a problem
joelo
11-18-2003, 11:32 AM
I've tried it and got the following error:
Microsoft VBScript compilation error '800a03ea'
Syntax error
/maintenance/project12/welljacketdatabaseedit.asp, line 238
sqlwrk & sqlwrk = "FROM [wellheaddatabase] "
-------^
this is the code:
<tr>
<td bgcolor="#0099CC"><font color="#FFFFFF"><font size="-1">WELLID</font> </font></td>
<td bgcolor="#F5F5F5"><font size="-1"><%
strsql = "SELECT * FROM [welljacketdatabase]"
Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open strsql, conn
x_WELLJACKETID = rs("WELLJACKETID")
x_WELLIDList = "<SELECT name='x_WELLID'><OPTION value=''>Please Select</OPTION>"
sqlwrk = "SELECT [WELLID] "
sqlwrk & sqlwrk = "FROM [wellheaddatabase] "
sqlwrk & sqlwrk = "WHERE (1+1) "
If x_WELLJACKETID <> "" Then
sqlwrk & sqlwrk = "AND WELLJACKETID ='"&X_WELLJACKETID&"'"
End If
sqlwrk & sqlwrk = "ORDER BY [WELLID]"
Set rswrk = Server.CreateObject("ADODB.Recordset")
rswrk.Open sqlwrk, conn, 1, 2
If Not rswrk.EOF Then
datawrk = rswrk.GetRows
rowswrk = UBound(datawrk, 2)
For rowcntwrk = 0 To rowswrk
x_WELLIDList = x_WELLIDList & "<OPTION value='" & datawrk(0, rowcntwrk) & "'"
If cstr(datawrk(0, rowcntwrk)&"") = cstr(x_WELLID&"") Then
x_WELLIDList = x_WELLIDList & " selected"
End If
x_WELLIDList = x_WELLIDList & ">" & datawrk(0, rowcntwrk) & "</option>"
Next
End If
rswrk.Close
Set rswrk = Nothing
x_WELLIDList = x_WELLIDList & "</SELECT>"
response.write x_WELLIDList
%>
</font> </td>
</tr>
slyfox
11-18-2003, 11:40 AM
i'm not too sure which caracter to use to append variables to each other... i'm not a vbscript expert
try
variable &= variable = ""
or whatever... play around
if it was asp - jscript then i could give you the right answer
joelo
11-18-2003, 11:49 AM
With the following code I don't get no errors but Its not selecting related datas based on the value of my Textbox (x_welljacketID) .... I am missing something but I don't what it is that I am missing
<td bgcolor="#0099CC"><font color="#FFFFFF"><font size="-1">WELLID</font> </font></td>
<td bgcolor="#F5F5F5"><font size="-1"><%
strsql = "SELECT * FROM [welljacketdatabase]"
Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open strsql, conn
x_WELLJACKETID = rs("WELLJACKETID")
x_WELLIDList = "<SELECT name='x_WELLID'><OPTION value=''>Please Select</OPTION>"
sqlwrk = "SELECT [WELLID] "
sqlwrk = sqlwrk & "FROM [wellheaddatabase] "
sqlwrk = sqlwrk & "WHERE (1=1) "
If x_WELLJACKETID <> "" Then
sqlwrk = sqlwrk & "AND WELLJACKETID ='"&X_WELLJACKETID&"'"
End If
sqlwrk = sqlwrk & "ORDER BY [WELLID]"
Set rswrk = Server.CreateObject("ADODB.Recordset")
rswrk.Open sqlwrk, conn, 1, 2
If Not rswrk.EOF Then
datawrk = rswrk.GetRows
rowswrk = UBound(datawrk, 2)
For rowcntwrk = 0 To rowswrk
x_WELLIDList = x_WELLIDList & "<OPTION value='" & datawrk(0, rowcntwrk) & "'"
If cstr(datawrk(0, rowcntwrk)&"") = cstr(x_WELLID&"") Then
x_WELLIDList = x_WELLIDList & " selected"
End If
x_WELLIDList = x_WELLIDList & ">" & datawrk(0, rowcntwrk) & "</option>"
Next
End If
rswrk.Close
Set rswrk = Nothing
x_WELLIDList = x_WELLIDList & "</SELECT>"
response.write x_WELLIDList
%>
</font> </td>
</tr>
slyfox
11-18-2003, 12:21 PM
here is an example of what you are looking for that i know works:
<Select name="Id">
<option value = "" selected>select</option>
<%While NOT objRS.EOF%>
<option value = "<%=objRS("id")%>"><%=objRS("Name")%></option>
<% objRS.MoveNext
Wend
objRS.Close
Set objRS = Nothing
objConn.Close
Set objConn = Nothing%>
</SELECT>
hope this helps you