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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Database query question

Status
Not open for further replies.

certizoid

Programmer
May 11, 2001
9
US
Hello,

Is it possible, and how - I created a form control on an HTML page that submits to an asp page on my server, the asp queries an access database, and properly return the average of a single column; however, this result is loaded into it's own window. How can I have the result displayed directly on a form control (text) next to the submit button.

see below for code snippets:

HTML:

<form method=&quot;get&quot; action=&quot;get_avg.asp&quot;>
<input type=&quot;text&quot; name=&quot;avg&quot; disabled>
<input type=&quot;submit&quot; name=&quot;sub&quot;>
</form>


ASP:

set rs = Server.CreateObject(&quot;ADODB.recordset&quot;)
rs.Open &quot;Select AVG(score) from average&quot;, conn
do until rs.EOF
for each x in rs.Fields

Response.Write(x.value)

next
Response.Write(&quot;<br />&quot;)
rs.MoveNext
loop

Finally, is it possible to have the ASP page display to the HTML form control the results from the query on 'onload', thereby bypassing the need for the submit control.

Thanks in advance,

James S.
 
hi,
why not just hit the DB first and then write the avg to the client all on one page?
set rs = Server.CreateObject(&quot;ADODB.recordset&quot;)
rs.Open &quot;Select AVG(score) from average&quot;, conn

<form>
<input type=&quot;text&quot; name=&quot;avg&quot; value = <%=rs(0)%>

</form>

hope this helps

bastien
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top