Click to See Complete Forum and Search --> : Page Jump


Ninel
03-11-2003, 09:15 AM
This is sort of an HTML/ASP question.

In the tutorial I read that in order to have a page jump I need to use the following code : <A HREF="#Codeword">.

And where I want it to go I use this code:
<A NAME="Codeword">.

Let's say the page I'm using this code on is called products.asp. The issue I'm having is that I pass a quesrystring to the products.asp page. So when I get to the products.asp page the link ends up looking like this....

www.companyname.com/product.asp?type=1#Codeword

I think that becasue of the querystring the page jump doesn't work.

How can I get around this?

khaki
03-11-2003, 10:03 AM
Hi Ninel...

Can you define "jump"?

Are you trying to have the user go to a specific anchor in the page?

If so, it's:
<a href="jumpto.htm?#bottom">click</a>

and the "jumpto.htm" page would contain an anchor like this:
<a name="bottom">

Is that what you are talking about?
k

pyro
03-11-2003, 10:04 AM
You need to use the full link of your page. ie. <a href="product.asp#Codeword">

khaki
03-11-2003, 10:06 AM
huh?

pyro
03-11-2003, 10:13 AM
Basically, the same thing you said (posted at the same time). They will need to include the name of the page in their <a href> instead of just putting the #anchorname...

Ninel
03-11-2003, 10:41 AM
I included the name, but because it reads the querystring there is an error if I don't include the ?type=2 part.

But if I do include it then the page doesn't jump.

pyro
03-11-2003, 10:50 AM
I've never tried this, but it would be interesting to know if it works... Would it work to code your link with that anchor first, and then the query string? try <a href="product.asp#Codeword?type=2"> and let me know if it works.

Ninel
03-11-2003, 11:06 AM
A variable that I'm trying to read becomes empty when I try to jump.

Is the form submitting when the page jumps?

khaki
03-11-2003, 11:12 AM
oh... right.

hey... sorry Ninel... you started this using an ASP example and then I bastardized it.

there is nothing wrong with this:
<a href="product.asp?Type=1#bottom">click</a>

...and if this is in product.asp it will display the name/value:
<a name="bottom"><% =Request.QueryString%>
(as "Type=1")

As far as using the term "jump", I believe that some people use that word to refer to "calling" a sub or function (i'm not sure, since I'm self-taught and use the term "call")

What is it your trying to do?
Can you post more code maybe?
k

khaki
03-11-2003, 11:18 AM
oh!
I see that you say FORM!
(I missed that earlier).

Sorta the same, but different.
passedVar = request.form(Type)
(no querystring variables necessary)
where passedVar will = 1

Post your code.
(and this really belongs in the ASP forum).
k

khaki
03-11-2003, 11:39 AM
shoot!
am i confusing the crap out of you?
For the querystring method:
<a href="product.asp?Type=1#Codeword">
(not "bottom". that was my example).

Plus, to submit the form (instead of the querystring method), just use
<form action="product.asp#Codeword" method=post>
and retrieve the form's values using
request.form(formElementName)
(this also maintains your "jump" to the "Codeword" anchor - but you can ommit it).

Also... while it seems to work ok (in a stripped-down test page), I would shy away from using the name "Type ", since I believe that it is a reserved word, and it may come back to bite you in the ass sometime later (although I would like to here from someone who knows if that is true or not).

But really Ninel.....
code!. need some code.
k

Ninel
03-11-2003, 11:44 AM
Let me first explain the layout of my page:

At the top of the page:
iProdTypeId = Request.QueryString("type")

Then I use the variable to execute a query on an Access database:

Set rsEquipData = Server.CreateObject("ADODB.Recordset")
sSQL = "SELECT pn.ProdTypeId, pn.ProdId, pn.ProdName, pn.ProdDesc, pn.ProdPic FROM prodNames pn WHERE pn.ProdTypeId=" & iProdTypeId
rsEquipData.Open sSQL, cnConn

Then I want to see the link that jumps:

If iProdTypeId =2 Then
Dim a
a = "<p><A HREF='product.asp#Jump?type=" &
iProdTypeId & "'>Pre-owned and ReConditioned"
a = a & "</A> </p>"
Response.Write a
End If

And this is where I want the page to jump when the link is clicked:
<A NAME="jump"><%=sHTML%> (sHTML is a variable that contains the html)

Now the first time the page loads everything works properly.
When I click on the link to jump I believe the page submits and starts reading from the top.
My variable iProdTypeId is empty and when I try to execute the SQL statement I get ODBC error.

Why isn't it reading the ?type=1 querystring the 2nd time?

I hope all of this made sense.

khaki
03-11-2003, 01:47 PM
Why isn't it reading the ?type=1 querystring the 2nd time? It appears to me that for the 2nd time to be run at all, "type" has to
be equal to 2, not 1, in order for the IF statement to even execute.

If "type" is equal to 1 (or any other value than 2), your IF statement
has no conditional alternative (it ends without executing anything).

Also, it must read as follows:

if iProdTypeID = 2 then
Dim a
a= "<p><a href='product.asp?type=" & iProdTypeID & "#jump'>Pre-owned and ReConditioned"
a=a & "</a></p>"
response.write a
end if
(you have the anchor in the wrong place)

But once again, that will only execute if "type" is equal to 2.
(do you have multiple if/then statements that you did not show
here in your example?)

Try that first.
Then let me know if you are still having problems and I'll see if I
can try to understand your use of links ("jumps"). I'm having difficulty
understanding the logic of using them as you do, but there are always
many ways of doing things, so I'm willing to try to understand what you
are trying to accomplish here.
Let me know...
k

Ninel
03-11-2003, 02:38 PM
khaki,

Thank you so much for all your help. It finally worked.

Ninel

khaki
03-11-2003, 02:49 PM
C :) :) L !