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!

returning a query to a form control

Status
Not open for further replies.

certizoid

Programmer
May 11, 2001
9
US
certizoid (Programmer) May 22, 2001
Hello,

Is is 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 think you might want to post this in a forum on HTML or ASP Kathryn


 
I don't think there is a way to do what you are asking. The issue is that HTML is Connectionless (IE the server drops your connection as soon as it's done with your query)

and therefore, the system 'forgets' that you had a page there in the first place. The only way I can see of doing this so you and your clients see what you are asking for is to re-display the whole page after the ASP page has run.

Or just allow a small pop-up. depending on what you are looking for.

Now not to get TOO deep into things.. but you could set up an Iframe next to the form.. and have the ASP page change the Iform Page, and refreash THAT page.. there fore giving the Illusion that it's one page.. but then you'd only be able to see it with 4.0 browers.. and truthfully, the Iframe is a little flakly between Netscape, and IE.

hope this helps!

******
Darkness... Bleakness...
and Plastic forks...
--The PogoWolf
 
Hi PogoWolf,

Thanks for the thoughts. Since my post, I converted my HTML page to an ASP. I have the average working now, but I am now having problems with getting my page to insert a simple number into my database. I have the <%...%> embedded into a javascript function that should not be called until needed; however, on page load, the page stops loading at the <%...%> and shows an error in the viewed source, BUT only when a variable is used. when I use a constant, the database is updated ok...except that it updates at the wrong time (on page load)...

if you can, please check out my site, and give me your thoughts.


here is some of the ASP code for the 'presidential quiz'


Future issues: Decimal format for the average
The relative ugliness of the site :)
--------------------------------------------------
Sorry, the formatting got hosed...

<script language=&quot;javascript&quot;>

function check() //Check how many Presidents correct
{
var done = &quot;true&quot;;
correct=0;
for (i=0; i<presidents.length;i++)
if (final_array == &quot;Put a President Here&quot;)
done = &quot;false&quot;;
if (done == &quot;true&quot;)
{
for (i=0; i<presidents.length;i++)
if (presidents==final_array)
correct++;
alert(&quot;You got &quot; + correct + &quot; presidents correct&quot;)

<%set conn=Server.CreateObject
(&quot;ADODB.Connection&quot;) conn.Open &quot;average&quot;
sqlq= &quot;insert into average ( score ) values(correct) &quot; conn.BeginTrans
conn.execute (sqlq)
conn.CommitTrans
conn.close%>


}
else
alert(&quot;You are not done, please fill in entire list&quot;)

}
 
I just loaded the page with out error... and ran it with out problems.. how about if we switch this problem to Email.. it might make it a bit faster.=)

pogowolf@hotmail.com
******
Darkness... Bleakness...
and Plastic forks...
--The PogoWolf
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top