Where is my javascript error?

Experts,

I am using the following AJAX tabs script:  http://www.dynamicdrive.com/dynamicindex17/ajaxtabscontent/index.htm

I am nesting tabs using the script.  When I nest my tabs, I am getting the error as seen in the screen shot below.  The error does not occur if I am not nesting my tabs.  Can anyone help me diagnose my problem?

Here is my nested tabs code:
echo '<div class="controllers_message">';
echo '
<ul id="countrytabs" class="shadetabs">
<b>Admin Panel</b> > 
<li><a href="admin_routines.php?cmd=users" rel="countrycontainer">Users</a></li>
<li><a href="admin_routines.php?cmd=reports" rel="countrycontainer">Reports</a></li>
<li><a href="admin_routines.php?cmd=database" rel="countrycontainer">Database</a></li>
<li><a href="admin_routines.php?cmd=greeting" rel="countrycontainer">Greeting</a></li>
<li><a href="admin_routines.php?cmd=stats" rel="countrycontainer">Site Stats</a></li>
</ul>';

echo'
<div id="countrydivcontainer" style="border-top:1px solid gray; padding: 5px; margin-bottom:0px;">';
echo'</div>';

echo '
<script type="text/javascript">
	var countries=new ddajaxtabs("countrytabs", "countrydivcontainer")
	countries.setpersist(true)
	countries.setselectedClassTarget("link") //"link" or "linkparent"
	countries.init()
			
		countries.onajaxpageload=function(pageurl){
			
			if (pageurl.indexOf("admin_routines.php?cmd=users")!=-1){
			var user=new ddajaxtabs("usertabs", "userdivcontainer")
			user.setpersist(true)
			user.setselectedClassTarget("link") //"link" or "linkparent"
			user.init()
			}
																	
			if (pageurl.indexOf("admin_routines.php?cmd=reports")!=-2){
			var report=new ddajaxtabs("reporttabs", "reportdivcontainer")
			report.setpersist(true)
			report.setselectedClassTarget("link") //"link" or "linkparent"
			report.init()
			}
			
			if (pageurl.indexOf("admin_routines.php?cmd=database")!=-3){
			var database=new ddajaxtabs("databasetabs", "databasedivcontainer")
			database.setpersist(true)
			database.setselectedClassTarget("link") //"link" or "linkparent"
			database.init()
			}
			
		}	
									
</script>
';
echo '</div>';

Open in new window

Untitled-1.jpg
evibesmusicAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

moosely123Commented:
as the error refers to not being able to find a element on a page, it could be that you have have tab names wrong maybe? so are the tabs names correct in the follow snipets of code

var countries=new ddajaxtabs("countrytabs", "countrydivcontainer")
var user=new ddajaxtabs("usertabs", "userdivcontainer")
var report=new ddajaxtabs("reporttabs", "reportdivcontainer")
var database=new ddajaxtabs("databasetabs", "databasedivcontainer")
0
evibesmusicAuthor Commented:
@moosely123:

After my last post, I updated the script above to the following code and was able to elliminate two instances of the error message.  I now only get the error when I click on the 'Database' tab.  If I click on the 'Users' and 'Reports' tab, no error message appears.

I simply made the if statements into 'else if' statments.  Any thoughts now?  Maybe my naming conventions of the third tab?

Thanks for your help.

echo ' 
<script type="text/javascript"> 
        var countries=new ddajaxtabs("countrytabs", "countrydivcontainer") 
        countries.setpersist(true) 
        countries.setselectedClassTarget("link") //"link" or "linkparent" 
        countries.init() 
                         
                countries.onajaxpageload=function(pageurl){ 
                         
                        if (pageurl.indexOf("admin_routines.php?cmd=users")!=-1){ 
                        var user=new ddajaxtabs("usertabs", "userdivcontainer") 
                        user.setpersist(true) 
                        user.setselectedClassTarget("link") //"link" or "linkparent" 
                        user.init() 
                        } 
                                                                                                                                         
                        else if (pageurl.indexOf("admin_routines.php?cmd=reports")!=-2){ 
                        var report=new ddajaxtabs("reporttabs", "reportdivcontainer") 
                        report.setpersist(true) 
                        report.setselectedClassTarget("link") //"link" or "linkparent" 
                        report.init() 
                        } 
                         
                        else if (pageurl.indexOf("admin_routines.php?cmd=database")!=-3){ 
                        var database=new ddajaxtabs("databasetabs", "databasedivcontainer") 
                        database.setpersist(true) 
                        database.setselectedClassTarget("link") //"link" or "linkparent" 
                        database.init() 
                        } 
                         
                }        
                                                                         
</script> 
';

Open in new window

0
Dave BaldwinFixer of ProblemsCommented:
It looks to me like the definition of 'nested tabs' on Dynamic Drive isn't what you are doing.  They refer to other pages loaded with their own tabs, not tabs nested on the same page.
0
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

evibesmusicAuthor Commented:
@DaveBaldwin:

Please see this link for clarification:
http://www.dynamicdrive.com/dynamicindex17/ajaxtabscontent/ajaxtabs_suppliment2.htm

Cheers!
0
evibesmusicAuthor Commented:
@all:

Thanks for the attempted assistance but, I figured it out.  The code below shows what I had to do '!=-2' and '!=-3' should have been '!=-1'.

I am now getting another error: Unterminated String Constant

To be fair I will open another question.  Thanks to you both.  Cheers!
<script type="text/javascript">
	var countries=new ddajaxtabs("countrytabs", "countrydivcontainer")
	countries.setpersist(true)
	countries.setselectedClassTarget("link") //"link" or "linkparent"
	countries.init()
			
		countries.onajaxpageload=function(pageurl){
			
			if (pageurl.indexOf("admin_routines.php?cmd=users")!=-1){
			var user=new ddajaxtabs("usertabs", "userdivcontainer")
			user.setpersist(true)
			user.setselectedClassTarget("link") //"link" or "linkparent"
			user.init()
			}
																	
			else if (pageurl.indexOf("admin_routines.php?cmd=reports")!=-1){
			var report=new ddajaxtabs("reporttabs", "reportdivcontainer")
			report.setpersist(true)
			report.setselectedClassTarget("link") //"link" or "linkparent"
			report.init()
			}
			
			else if (pageurl.indexOf("admin_routines.php?cmd=database")!=-1){
			var database=new ddajaxtabs("databasetabs", "databasedivcontainer")
			database.setpersist(true)
			database.setselectedClassTarget("link") //"link" or "linkparent"
			database.init()
			}
			
		}	
									
</script>

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Dave BaldwinFixer of ProblemsCommented:
Ok, I've read that.  The only thing I can see that might be wrong is that all 3 "if" statements should have "!=-1" instead of "!=-2" or "!=-3".  "-1" is the error return for the 'indexOf' not being found according to this page http://www.w3schools.com/jsref/jsref_indexOf.asp.
0
enggagrawalCommented:
after eash javascript statement there should be delimiter
echo '<script type="text/javascript">';
       echo ' var countries=new ddajaxtabs("countrytabs", "countrydivcontainer");';
        echo 'countries.setpersist(true);';
        echo 'countries.setselectedClassTarget("link") //"link" or "linkparent";';
       ----
----
                                                                       
echo '</script>';
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
AJAX

From novice to tech pro — start learning today.