Hi there, I'm new to the IT industry. I will finish my bachelor's degree in a few weeks. I would like a little help on a small part of functionality I wish to include in my final project.
Basically I would like to send across a variable in the browser and retrieve it using the $_get function. I want to add a #name anchor to the end of the address so when the page loads, it loads to the bottom of the page whilst retrieving the relevant content that applies to the variable being sent through the address bar.
My code is similar to this structure:
So when page loads It should go to bottom whilst passing the variable to that page. It works... kind of, I can get the variable fine and it loads dynamically and accordingly to the variable sent by retrieving it using the $_get function. But does not go to where "imagenav" is located.
I tried this by manually setting the variable $cr or $cl to a static value, the same thing happened, however when I clicked it a second time, the page focused to the bottom of the screen where "imagenav" is located (obviously the page content remained the same the second time around it was clicked).
Any help is appreciated. Also i'm new here, so if in wrong forum please redirect me.
I am not quite sure I have fully understood what you are trying to do but it appears that you are trying to pass a variable/value using $_GET and use it to trigger the anchor point (and presuming $imagenav = $_GET['imagenav'], in which case:
I think its simpler than what your trying to suggest!
imagenav is not a variable. It is the ID of the div specified, so when the link is clicked and page has loaded, it loads and focuses to where <div id="imagenav"></div> is located.
Note: The variable/value is used to get an ID and use that to display an image/description using $_get. (Which works fine.)
-> Then... to anchor point to the DIV named "imagenav"
I hope that makes sense? In otherwords, Can I combine a $_get variable with a #anchorpoint in the one link? and how do I do that?
Sorry, I missed the div (it was late at night ). However, you can't focus a link on a div, you have to use an anchor point so you would need to change the div to an anchor point or add in the anchor point by/within the div, for example
Code:
<div id="imagenav"><a name="imagenav"></a></div>
// OR just
<a name="imagenav"></a>
Then your link code should work as I can't see anything wrong with that.
<a> tag or <div> tag its still behaving the same for me. Like I said, The variable changes and the page loads new content each time the user clicks that left or right button. The browser seems to be ignoring the Anchor point because of this somehow... If this variable doesn't change and I set it to a specific value, the second time around it is clicked, it works... I'm not sure, Maybe I'm loading the page twice or something... Thanks for help but its probably something wrong with how the rest of my code is executing.
Bookmarks