Author |
Topic |
Alfred
Senior Member
USA
1527 Posts |
Posted - 20 October 2003 : 12:49:25
|
I have made subs in the file for each case of numbers of days. I want to make the numbers into links, so the user can choose the stats he wants to see: Statistics for 7, 30, 60, 90, days. I don't want to make separate pages or files for each case, to avoid slowing down the process. My question is how does one make a link to a sub in the same file? |
Alfred The Battle Group CREDO
|
|
redbrad0
Advanced Member
USA
3725 Posts |
Posted - 20 October 2003 : 13:42:01
|
well if your sub excepts variables example:
sub dispaystats(tDate) ' # sub goes here end sub
then you can just pass it thru the querystring
page.asp?show=7
then call it out by just doing..
call dispaystats(Request.QueryString("show")) |
Brad Oklahoma City Online Entertainment Guide Oklahoma Event Tickets |
|
|
Alfred
Senior Member
USA
1527 Posts |
Posted - 20 October 2003 : 14:12:06
|
Sorry, I don't follow this at all. The subs run the stats for the corresponding number of days. I would like the day numbers (7, 30, 60, 90,) to function as links to the subs.
|
Alfred The Battle Group CREDO
|
|
|
redbrad0
Advanced Member
USA
3725 Posts |
|
Alfred
Senior Member
USA
1527 Posts |
Posted - 20 October 2003 : 15:11:27
|
It is just one line on the page, with the numbers on the left, and the sub filling in the data in the same line. The data should change depending on what number the user clicks on, the same way as one would call a bookmark in an htm page. |
Alfred The Battle Group CREDO
|
|
|
D3mon
Senior Member
United Kingdom
1685 Posts |
Posted - 20 October 2003 : 16:59:00
|
To change the data displayed on the page you will have to reload the same page again. What redbrad0 was saying was that you tell the new page what to show by making your links add information to the querystring. When ASP is run, it's a one-time operation, until the page is called again.
You can make the same page do different things (like showing different ranges of statistics) by giving it instructions on how to run, by submitting a form or passing one or more variables in a query string.
A Sub is just a section of code that may or may not be run as part of executing the page as a whole. Once the page has been executed you can't then ask it just to go and run a Sub. |
Snitz 'Speedball' : Site Integration Mod : Friendly Registration Mod "In war, the victorious strategist only seeks battle after the victory has been won" |
|
|
laser
Advanced Member
Australia
3859 Posts |
Posted - 20 October 2003 : 17:50:49
|
Alfred, I think you need to read Brad's first post again - I think that is the key to your requirement. Snitz itself has examples of this, or easier might be a page like :
http://www.v8central.com/v8supercar/2003points.asp
see the numbers across the top ? .. is this what you mean ? |
|
|
Alfred
Senior Member
USA
1527 Posts |
Posted - 20 October 2003 : 18:07:12
|
d3mon: I see what you are saying - so it actually is no time loss to simply make it a regular htm link, since the page has to be reloaded in any case.
laser: I think I have read Brad's instructions 20 times, but got no smarter from it. The page you linked to (at your site) is exatly what I need to do, except that in my case it only changes the one line instead of popping up a whole table. That could be done just by a simple htm link though, couldn't it? Anyway, I copied your code for this line:quote: <a href='news.asp?sevendays=7'>7,</a> <a href='news.asp?thirtydays=30'>30,</a> <a href='news.asp?sixtydays=60'>60,</a> <a href='news.asp?ninetydays=90'>90,</a> days stats:
Now I have the links - how do I have to mark the subs that it finds them? Simply placing a number in the second line like this: sub sevendays 7 does not do it. |
Alfred The Battle Group CREDO
|
Edited by - Alfred on 20 October 2003 19:21:31 |
|
|
redbrad0
Advanced Member
USA
3725 Posts |
|
laser
Advanced Member
Australia
3859 Posts |
Posted - 20 October 2003 : 20:11:01
|
Alfred, you're close but this would be easier to use :
<a href='news.asp?days=7'>7,</a>
<a href='news.asp?days=30'>30,</a>
<a href='news.asp?days=60'>60,</a>
<a href='news.asp?days=90'>90,</a> days stats:
Then in your code, you just refer to "days" and it will have the proper number in it. You can insert that number into SQL or anything without REALLY knowing what they chose |
|
|
Alfred
Senior Member
USA
1527 Posts |
|
Alfred
Senior Member
USA
1527 Posts |
Posted - 20 October 2003 : 20:46:28
|
laser: Like so: quote: <a href='news.asp?days=7'>7,</a> <a href='news.asp?days=30'>30,</a> <a href='news.asp?days=60'>60,</a> <a href='news.asp?days=90'>90,</a> days stats:
But I still don't know the tag I need to put in the sub so it can be found by the link! |
Alfred The Battle Group CREDO
|
|
|
Nikkol
Forum Moderator
USA
6907 Posts |
Posted - 20 October 2003 : 21:12:33
|
alfred, the link doesn't find anything ... it's the sub that finds something based on the link. here's a general example:
let's say mypage.asp looks like:
<%
response.write "<a href=""mypage.asp?days=7"">7 days</a><br/>"
response.write "<a href=""mypage.asp?days=30"">30 days</a><br/>"
response.write "<a href=""mypage.asp?days=60"">60 days</a><br/>"
days = request.querystring("days")
if days <> "" then Call MySub(days)
Sub MySub(fDays)
response.write "The date " & fDays & " ago was " & DateAdd("d",-1*CInt(fDays),Now()) & "."
End Sub
%>
The page has a subroutine right in it, but it could also be in another file that is included in mypage.asp. Anyhow, if you first bring up mypage.asp in your browser, you will only see:
7 days 30 days 60 days
and if you click on the link for 30 days, you will see something like:
7 days 30 days 60 days The date 30 days ago was 9/20/2003 20:51:03. |
Nikkol ~ Help Us Help You | ReadMe | 3.4.03 fixes | security fixes ~ |
|
|
Alfred
Senior Member
USA
1527 Posts |
Posted - 20 October 2003 : 22:46:32
|
I transformed this info as well as I could into my code: http://www.ggholiday.com/bg/forums/news.txt and when I wrote the if statements (lines 104-115) I sudddenly got an error for the default.asp file, in which the news.asp is included via inc_header.asp.quote:
Error Type: Microsoft VBScript compilation (0x800A03F6) Expected 'End' /BG/forums/default.asp, line 1089
I thought I had ended the if statement: quote: if days = 7 then Call sevendays
else if days = 60 then Call sixtydays
else if days = 90 then Call ninetydays
else call thirtydays end if
|
Alfred The Battle Group CREDO
|
|
|
Nikkol
Forum Moderator
USA
6907 Posts |
|
Nikkol
Forum Moderator
USA
6907 Posts |
Posted - 20 October 2003 : 23:02:59
|
also, why do you have separate subs for each choice? use my example and use only one sub.
and you have pure html stuck in those subs ... that's going to cause you a problem. you should convert that to response.write's |
Nikkol ~ Help Us Help You | ReadMe | 3.4.03 fixes | security fixes ~ |
Edited by - Nikkol on 20 October 2003 23:04:46 |
|
|
Topic |
|