Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query from Select Box

Status
Not open for further replies.

Dorff

Programmer
Mar 13, 2002
72
CA
I have a select box on my page near the bottom of my form. When the user is done filling out the form they select one of the options from this select box and I want them to be able to see the information pertaining to the selected option in a generated table on the same page. In plain english, they select a team name, and I want the name of the members to show up. I understand that ASP must be run at load time, but I really need a solution for this. I don't want to have to use Remote Scripting and there has to be another way to run a query in the middle of a page.

The main problem here being that if they want to see the team members and the page reloads to do the query, the information in the rest of the form is lost.

Thanks in advance. Ryan
rmindorff@hotmail.com
 
You could also do something like this:

Put the following into an asp page called
<%@ Language=VBScript %>
<HTML>
<BODY>
<SCRIPT LANGUAGE=VBScript>


Sub ButtonClick()
sServer=&quot;put your webserver name here&quot;

' Create a new recordset.
Set oRS = CreateObject(&quot;ADODB.Recordset&quot;)

sSQL = &quot;SQL Statement here&quot;

oRS.Open &quot; & sServer & &quot;/Getdata.asp?SQL=&quot; & sSql

while not oRS.EOF
document.all(&quot;result&quot;).innerHTML=document.all(&quot;result&quot;).innerHTML & oRS(&quot;fieldname&quot;)
oRS.MoveNext
wend


End Sub
</SCRIPT>
<INPUT type=button value=&quot;Get Data From Another ASP page&quot; onclick=&quot;VBScript:ButtonClick&quot;>
<div id=result>

</div>
</BODY>
</HTML>

Put the following into another page called GetData.asp

<%@ Language=VBScript %>
<%
Dim oConn,oRS,strConn,sSQLServer

' Build the connection string.

strConn = &quot;put your database connection string here&quot;
' Set our return content type.
Response.ContentType = &quot;text/xml&quot;

' Create a connection.
set oConn = Server.CreateObject(&quot;ADODB.Connection&quot;)
' Open the connection.
oConn.Open strConn
' Execute the SQL statement.
set oRS = oConn.Execute(Request.QueryString(&quot;SQL&quot;))
' Save the recordset in the Response object.
oRS.Save Response,1
%>

On the first page:
set variable sServer
make sure the oRS.open points to where you pur the GetData.asp page

On GetData.asp page
set a valid connection string

Try the example.
This will work as long as ADO is installed on the client machine.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top