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 1

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.
 
I cant answer the bit about ASP, as I use PHP, but for the second bit...

give the form a name...so :

<form name=&quot;avgForm&quot; 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>

Then stick this javascript in to body tags or whatever needs to be loaded.

onload=&quot;document.avgForm.submit()&quot;

This is essentially what the submit button does.


Hope this helps. Chris MacPherson
macpweb@hotmail.com
Bring on the new Browza's!!
 
Thanks for the help, that solved the second part. If anyone has a solutoin for the first part, I will be all set.

To see what I am upto, please examine this, you will see the problem.


Thanks all :)
 
For now, I have to remove the onload in the body. When I get the control to work, I can reinsert the auto-submit.
 
Sorry, I feel like a moron! If you check out the site, please access the 'Presidential Quiz' menu item.

Jim S.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top