PDA

View Full Version : Tab Content Script - change on load?



ak7861
10-09-2006, 07:43 AM
1) Script Title:

Tab Content Script

2) Script URL (on DD):

http://www.dynamicdrive.com/dynamicindex17/tabcontent2.htm

3) Describe problem:

I need a on load function for this script for my body tag which will do an auto switch to 'sc2'.. for eg.


<body onLoad="expandcontent('sc2', this);">

However this doesnt work for me. Anyone?

ddadmin
10-09-2006, 08:13 AM
Hmmm are you basically just trying to load the tab content "sc2" when the page initially loads? The script provides an internal way to do this:


//Set tab to intially be selected when page loads:
//[which tab (1=first tab), ID of tab content to display]:
var initialtab=[2, "sc2"]

codeexploiter
10-09-2006, 08:39 AM
posted by: ak7861

<body onLoad="expandcontent('sc2', this);">


The above mentioned code will not work because if you look at the function call closely there is a 'this' which is used to pass the current object from the hyperlinks (tabs). In the original source code the author has used this with the hyerlinks to pass the current hyperlink object from which they are calling it.

Now either you can go with the solution provided by DDAdmin or you call the expandcontent() and pass the hyperlink obect to which you want to switch.

ak7861
10-09-2006, 08:48 AM
so what do i put exactly?

djr33
10-09-2006, 09:15 AM
This...
Hmmm are you basically just trying to load the tab content "sc2" when the page initially loads? The script provides an internal way to do this:


//Set tab to intially be selected when page loads:
//[which tab (1=first tab), ID of tab content to display]:
var initialtab=[2, "sc2"]

ak7861
10-09-2006, 09:19 AM
<? if (isset($_COOKIE["sspoll1"])) { ?><body><script>//Set tab to intially be selected when page loads:
[which tab (1=first tab), sc2]:
var initialtab=[2, "sc2"]</script><? } else { ?>


i tried this.. doesnt work..

codeexploiter
10-09-2006, 09:36 AM
var initialtab=[2, "sc2"]

This worked correctly for me. It loaded the 2nd tab as the default one rather than the first tab.

ddadmin
10-09-2006, 10:38 AM
ak7861:
Are you trying to use PHP to output this script somehow based on PHP's cookie value? That's probably the source of your problem- how you're integrating the two, which unfortunately only you know the full details (ie: have access to the entire PHP server side code).

ak7861
10-09-2006, 07:16 PM
Okay. I know where I went wrong. I didn't realize that the code you gave me was part of the script itself. So I just added the php cookie code in there, so if the cookie exists, it loads the second slide.

Thanks!