homepage Welcome to WebmasterWorld Guest from 54.166.108.167
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

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.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved