Home arrow ASP arrow Page 4 - Grabbing Data On The Fly
ASP

Grabbing Data On The Fly


When we're querying a database, we will usually need to press a submit button on a form to pass data to another ASP page, which would generate the query, and return the results. In some situations, this page refresh is just plain annoying and takes too long to complete. In this article, Phanix will describe another way to query a database using a combination of web technologies.

Author Info:
By: Phanix Chen
Rating: 5 stars5 stars5 stars5 stars5 stars / 8
December 08, 2001
TABLE OF CONTENTS:
  1. · Grabbing Data On The Fly
  2. · Some methods for passing data around
  3. · Using frames to solve the refresh problem
  4. · Query and return
  5. · The processframe.asp page
  6. · Conclusion

print this article
SEARCH DEVARTICLES

Grabbing Data On The Fly - Query and return
(Page 4 of 6 )

Firstly, we will want to submit the query keyword in our “MainFrame” frame to the “ProcessFrame’” frame. Create a new page named addbook.asp. Enter the following code into addbook.html:

<html>

<head>

<title> Add Book </title>

</head>

<frameset cols="100%, 0%" frameborder="no">

<frame name="MainFrame" src="mainframe.asp" border="0" noresize>

<frame name="ProcessFrame" src="processframe.asp" border="0">

</frameset>

</html>


We have created a new page that contains a frameset. Inside of the frameset, we have two frames: Our main frame, and the frame that will execute an SQL query in the background, “ProcessFrame”.

Create a new file named mainframe.asp, and enter the following code into it:

<html>

<head>

<title> Add Author</title>

<script language="JavaScript">

function SubmitAuthorQuery()

{

top.ProcessFrame.location.href = 'processframe.asp?authorQuery='+document.form1.authorQuery.value;

alert(top.ProcessFrame.location.href);

}

</script>

</head>

<body leftmargin="20" topmargin="20" marginwidth="20" marginheight="20">

<h1>Add Book</h1>

<form name="form1" action="mainframe.asp" method="post">

Book Title: <input type="text" name="bookTitle"><br>

ISBN: <input type="text" name="bookISBN"><br>

Author: <select name="bookAuthor"></select>

[ Query: <input type="text" name="authorQuery">

<input type="button" value="Query" onClick="SubmitAuthorQuery()"> ]<br><br>

<input type="submit" value="Add Book">

</form>

</body>

</html>


Our example is fairly simple, and we won’t be concentrating on actually adding the book to the database, rather the code to get a list of authors based on a keyword.

When we click on the “Query” button, the JavaScript SubmitAuthorQuery() function will be called. The SubmitAuthorQuery() function simply changes the URL of the “ProcessFrame” frame to processframe.asp?authorQuery=[query keyword], getting the value of [query keyword] from the “authorQuery” field in form1.

To actually execute the SQL query and return the results to the “MainFrame” frame, we need to create the processframe.asp page, so let’s do that now.
blog comments powered by Disqus
ASP ARTICLES

- Central Scoreboard with Flash and ASP
- Calorie Counter Using WAP and ASP
- Creating PGP-Encrypted E-Mails Using ASP
- Be My Guest in ASP
- Session Replacement in ASP
- Securing ASP Data Access Credentials Using t...
- The Not So Ordinary Address Book
- Adding and Displaying Data Easily via ASP an...
- Sending Email From a Form in ASP
- Adding Member Services in ASP
- Removing Unconfirmed Members
- Trapping HTTP 500.100 - Internal Server Error
- So Many Rows, So Little Time! - Case Study
- XDO: An XML Engine Class for Classic ASP
- Credit Card Fraud Prevention Using ASP and C...

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 

Developer Shed Affiliates

 




© 2003-2017 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials