Results 1 to 7 of 7

Thread: Pass parameters through URL

  1. #1
    Join Date
    Sep 2008
    Location
    Bristol - UK
    Posts
    842
    Thanks
    32
    Thanked 132 Times in 131 Posts

    Default Pass parameters through URL

    Ok, so I recently redid my site, so there are multiple pages on one.

    You can see an example of this here:

    http://bombthehills.com/newstuff/guides.html

    Just press the tabs and you'll see what I mean.

    But I do have other pages that link back to, for example, the "board maintenance" tab, but it's still on the guides.html page.

    And the content for it is contained in a div, so I want this sort of thing, but translated into a URL if it's possible:

    document.getElementById('maintenance').style.display='block';

    Is this possible? maybe not even this, but something that has the same effect. I hope it can be done, since I really want to have content put in tabs like this, where the page doesn't change.

    Thanks very much for any help given,

    Jack.

  2. #2
    Join Date
    Sep 2005
    Location
    India
    Posts
    1,627
    Thanks
    6
    Thanked 107 Times in 107 Posts

    Default

    In your approach I think two JS functions are using for hiding/showing the tabs; one for hiding all the tab content div element and another one for showing the needed div element.

    I think you can use the following function and associate this function and pass the element id which clicked. Maintain an element ID array inside the function through which you can display and hide the div element. The logic is to display the div element whose ID passed into the function rest of the elements will be hidden.

    Code:
    function displayTheClickedTab(clickedId){
    	var tabContentId = ['intro','maintenance','ridetips','tricktips']; //Enter the element ids which is the container of the tabs like the mentioned ones.
    	if(document.getElementById(clickedId)){
    		document.getElementById(clickedId).style.display = 'block';
    	}
    	
    	for(var i = 0; i < tabContentId.length; i++){
    		if(tabContentId[i] !== clickedId){
    			document.getElementById(tabContentId[i]).style.display = 'none';
    		}
    	}
    }
    Hope this helps

  3. The Following User Says Thank You to codeexploiter For This Useful Post:

    Schmoopy (12-01-2008)

  4. #3
    Join Date
    Sep 2008
    Location
    Bristol - UK
    Posts
    842
    Thanks
    32
    Thanked 132 Times in 131 Posts

    Default

    Yea, thanks very much for that - helps condense the code into one function which will definitely save time and space, I knew it could be done but I'm not really experienced enough at JavaScript to know how to do it.

    Anyway, maybe this makes it easier to pass that function through a URL?

  5. #4
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    http://www.dynamicdrive.com/dynamici...tabcontent.htm

    (v 2.2) A link from another page linking to the target page can select a tab on the later when loaded, via the URL parameter string ((ie: http://mysite.com/tabcontent.htm?tabinterfaceid=0).
    Last edited by jscheuer1; 12-01-2008 at 09:04 AM. Reason: add info
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  6. #5
    Join Date
    Sep 2008
    Location
    Bristol - UK
    Posts
    842
    Thanks
    32
    Thanked 132 Times in 131 Posts

    Default

    Thanks for that, but I'm still not sure how I would do it on my page, the code on that page seems very complicated, any way I could condense it down without having to copy a load off of that script?

    Would it be something like: www.bombthehills.com/guides.html?displayTab=1

    ?

  7. #6
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    You could write your own code to snag the query string from the URL and to then do something with it. But that seems about as complicated, if not more so, as using the script I suggest. With the Dynamic Drive script, all you have to do is follow the instructions.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  8. #7
    Join Date
    Sep 2008
    Location
    Bristol - UK
    Posts
    842
    Thanks
    32
    Thanked 132 Times in 131 Posts

    Default

    Yea, thanks for that, I've implemented the new tab code, but still having problems - follow on thread here: http://www.dynamicdrive.com/forums/s...ad.php?t=39276

    Edit: How has this got over 3000 views in a day? :S, bot?
    Last edited by Schmoopy; 12-01-2008 at 04:28 PM.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •