page refresh after query

M

mvprofessor

I'm displaying records queried on a date field, automatically displaying the
current date's data on page load. I have a text box displaying the query
date, with "prev" and "next" buttons (and then a "go" button) to select
another date. My problem is that when the new query results appear, the
default date in my query form is set back to the current date (I assume
because of a page refresh), and I want it to keep the last query date. In
other words, the viewer can't continuously query consecutive dates with just
one "prev" or "next" click - he has to keep starting over from the current
date. The only solution I can think of is to give him a session cookie with
his last query date and check for it on page load. Is there some way to
refresh the database results table and leave my query form alone?
 
S

Stefan B Rusynko

You don't want a session variable
- since the date requested changes w/ each page
(you would then have to reset the session variable on each page)
Depends on your original query
- if it is for today's (or any specific) date, then there is no next or previous
(there would only be 1 recordset for today's (or any specific) date)

The currently displayed date should be a hidden form field
<input type="hidden" name="ShowDate" value="<%=ShowDate%>">

Your 2 "buttons", Next/Prev, should be a single radio button field name say: Direction

<p>Next:<input type="radio" value="1" name="Direction" checked>Prev:<input type="radio" value="-1" name="Direction"></p>

On Submit the page (probably the same page) would read the form field value of the ShowDate and Direction fields (below code would
be above your form)

<%
If RequestForm("ShowDate") <>"" Then
ShowDate=RequestForm("ShowDate")
If RequestForm("Direction")<>"" Then
ShowDate=DateAdd("d",Cint(RequestForm("Direction")),ShowDate)
End If
Else
ShowDate=Date()
End If
%>
And your query string would be something like:

<%
Select * From Tablename Where Datefieldname=#" & ShowDate & "#"
%>

Note: You will need to add code for no record found in your results
(when your table does not have a record set for a specific date generated by ShowDate)

--

_____________________________________________
SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
"Warning - Using the F1 Key will not break anything!" (-;
_____________________________________________


| I'm displaying records queried on a date field, automatically displaying the
| current date's data on page load. I have a text box displaying the query
| date, with "prev" and "next" buttons (and then a "go" button) to select
| another date. My problem is that when the new query results appear, the
| default date in my query form is set back to the current date (I assume
| because of a page refresh), and I want it to keep the last query date. In
| other words, the viewer can't continuously query consecutive dates with just
| one "prev" or "next" click - he has to keep starting over from the current
| date. The only solution I can think of is to give him a session cookie with
| his last query date and check for it on page load. Is there some way to
| refresh the database results table and leave my query form alone?
 
M

mvprofessor

Thanks for the quick response. I should have explained I'm a rookie, using
the FP database wizard and a little javascript. I'll work on trying to
understand your suggestions, but meanwhile, if you have the time, you can see
what I'm trying to do at http://mvlivemusic.com/schedule.asp. By the way, a
previous version of this page actually displayed a results table for the
current date on page load, but I've been making experimental changes and now
I can't even get it to do that.
 
M

mvprofessor

My mistake... the problem wasn't in the page reloading, it was in my
javascript execution.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top