Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Community Forums
 Code Support: ASP (Non-Forum Related)
 How do you link to subs?
 New Topic  Topic Locked
 Printer Friendly
Next Page
Author Previous Topic Topic Next Topic
Page: of 3

Alfred
Senior Member

USA
1527 Posts

Posted - 20 October 2003 :  12:49:25  Show Profile  Visit Alfred's Homepage
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  Show Profile  Visit redbrad0's Homepage  Send redbrad0 an AOL message
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
Go to Top of Page

Alfred
Senior Member

USA
1527 Posts

Posted - 20 October 2003 :  14:12:06  Show Profile  Visit Alfred's Homepage
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
Go to Top of Page

redbrad0
Advanced Member

USA
3725 Posts

Posted - 20 October 2003 :  14:23:11  Show Profile  Visit redbrad0's Homepage  Send redbrad0 an AOL message
I guess i am lost, sorry

Brad
Oklahoma City Online Entertainment Guide
Oklahoma Event Tickets
Go to Top of Page

Alfred
Senior Member

USA
1527 Posts

Posted - 20 October 2003 :  15:11:27  Show Profile  Visit Alfred's Homepage
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
Go to Top of Page

D3mon
Senior Member

United Kingdom
1685 Posts

Posted - 20 October 2003 :  16:59:00  Show Profile  Visit D3mon's Homepage
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"
Go to Top of Page

laser
Advanced Member

Australia
3859 Posts

Posted - 20 October 2003 :  17:50:49  Show Profile
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 ?
Go to Top of Page

Alfred
Senior Member

USA
1527 Posts

Posted - 20 October 2003 :  18:07:12  Show Profile  Visit Alfred's Homepage
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
Go to Top of Page

redbrad0
Advanced Member

USA
3725 Posts

Posted - 20 October 2003 :  19:28:40  Show Profile  Visit redbrad0's Homepage  Send redbrad0 an AOL message
you have a different subs for each set of days? you could have it all in one sub. if you paste your sub i can take a look at making it one sub

Brad
Oklahoma City Online Entertainment Guide
Oklahoma Event Tickets
Go to Top of Page

laser
Advanced Member

Australia
3859 Posts

Posted - 20 October 2003 :  20:11:01  Show Profile
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
Go to Top of Page

Alfred
Senior Member

USA
1527 Posts

Posted - 20 October 2003 :  20:41:41  Show Profile  Visit Alfred's Homepage
redbrad0:
I put up the news.txt file which has the subs for 7, 30, 60, 90 days at the end:http://www.ggholiday.com/bg/forums/news.txt
Thanks for the help, and apologies for being so thick!

Alfred
The Battle Group
CREDO
Go to Top of Page

Alfred
Senior Member

USA
1527 Posts

Posted - 20 October 2003 :  20:46:28  Show Profile  Visit Alfred's Homepage
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
Go to Top of Page

Nikkol
Forum Moderator

USA
6907 Posts

Posted - 20 October 2003 :  21:12:33  Show Profile
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 ~
Go to Top of Page

Alfred
Senior Member

USA
1527 Posts

Posted - 20 October 2003 :  22:46:32  Show Profile  Visit Alfred's Homepage
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
Go to Top of Page

Nikkol
Forum Moderator

USA
6907 Posts

Posted - 20 October 2003 :  23:01:06  Show Profile
looks like you might have an extra end if on line 39 of your news file.

Nikkol ~ Help Us Help You | ReadMe | 3.4.03 fixes | security fixes ~
Go to Top of Page

Nikkol
Forum Moderator

USA
6907 Posts

Posted - 20 October 2003 :  23:02:59  Show Profile
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
Go to Top of Page
Page: of 3 Previous Topic Topic Next Topic  
Next Page
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.48 seconds. Powered By: Snitz Forums 2000 Version 3.4.07