How can I keep these two Javascripts from arguing with one another?

I've got a page with a Javascript clock on it. The script looks like this:

<SCRIPT LANGUAGE="JavaScript">
<!--  Clock --
var timerID = null
var timerRunning = false

function stopclock(){
	if(timerRunning)
		clearTimeout(timerID)
	timerRunning = false
}

function startclock(){
	stopclock()
	showtime()
}

function showtime(){
	var now = new Date()
	var hours = now.getHours()
	var minutes = now.getMinutes()
	var seconds = now.getSeconds()
	var timeValue = "" + ((hours > 12) ? hours - 12 : hours)
	timeValue  += ((minutes < 10) ? ":0" : ":") + minutes
	timeValue  += ((seconds < 10) ? ":0" : ":") + seconds
	timeValue  += (hours >= 12) ? " P.M." : " A.M."
	document.clock.face.value = timeValue 
	timerID = setTimeout("showtime()",1000)
	timerRunning = true
}
//-->
</script>

Open in new window


The body tag uses this to get the clock up and moving:

<body onLoad="startclock()">

The "arguing" starts when I introduce this:


<script type="text/javascript">
window.onload = function () {
var countrylist = new MSDList("countrylist");
countrylist.render();
};
</script>

It's a great little script that allows for a pulldown multiple select box. It has a library that goes along with it. The header, as far as my Javascript and JQuery looks like this:

<script type="text/javascript" src="MSDList.js"></script>
<script type="text/javascript" src="../js/jquery-1.7.1.min.js" ></script>
<script type="text/javascript" src="../js/jquery.tablesorter.js"></script>

The pulldown doesn't work as long as I've got this going on for my opening body tag:

<body onLoad="startclock()">

When I take that out, the clock doesn't work, but the pulldown does.

What can I change so that both work?
brucegustPHP DeveloperAsked:
Who is Participating?
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.

chaauCommented:
Just add the startclock to your countrylist onload function:
<script type="text/javascript">
window.onload = function () {
var countrylist = new MSDList("countrylist");
countrylist.render();
startclock();
};
</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
brucegustPHP DeveloperAuthor Commented:
Perfect!

Thanks so much!
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
JavaScript

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.