homepage Welcome to WebmasterWorld Guest from 23.22.252.150
register, login, search, subscribe, help, library, PubCon, announcements, recent posts, open posts,
Subscribe to WebmasterWorld
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library : Charter : Moderators: whoisgregg

JavaScript and AJAX Forum

    
getElementById Help
brnm98105




msg:4024044
 8:33 pm on Nov 12, 2009 (gmt 0)

Hi everyone,

Im looking for some help.

I have a site that has people in several areas of the country. Im building a dropdown that will show that specific location. The script looks like this

<script type="text/javascript"><!--
var lastDiv = "";
function showDiv(divName) {
// hide last div
if (lastDiv) {
document.getElementById(lastDiv).className = "hiddenDiv";
}
//if value of the box is not nothing and an object with that name exists, then change the class
if (divName && document.getElementById(divName)) {
document.getElementById(divName).className = "visibleDiv";
lastDiv = divName;
}
}
//-->
</script>

Now there are not any peole in some areas so Id like to create a code that will do that to. For example:

"No one is in that area. Be the first"

Is there something I can do to create this script without just duplicating "No one is in that area. Be the first" so many times on the page?

Does this make sense? Thanks in advance

 

daveVk




msg:4024260
 7:11 am on Nov 13, 2009 (gmt 0)

<script type="text/javascript"><!--
var lastDiv = "";
function showDiv(divName) {
if ( divName !== "" ) {
// hide last div
if (lastDiv) {
document.getElementById(lastDiv).className = "hiddenDiv";
}
//if value of the box is not nothing and an object with that name exists, then change the class
if (document.getElementById(divName)===null) {divName="welcomeId"; }
document.getElementById(divName).className = "visibleDiv";
lastDiv = divName;
}
}

//-->
</script>

HTML
<div id="welcomeId" class="hiddenDiv" >....</div>

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About
WebmasterWorld ® and PubCon ® are a Registered Trademarks of Pubcon Inc.
© Pubcon Inc. 1996-2012 all rights reserved