Small width layout Medium width layout Maximum width layout Small text Medium text Large text
     Search
Downloads Downloads Directory Directory Forums Forums Forge Forge Blogs Blogs        Marketplace Marketplace Careers Program Careers
Community › Forums Register  |  

PortalWebHosting
  Ads  
r2i.ntegrated
 


  Sponsors  

Meet Our Sponsors

ExactTarget email software solutions
Merak Mail Server
WebSecureStores -- ASP.NET & DotNetNuke Hosting Solutions
FCKeditor Project
Salaro -- Skins and more
OnyakTech
 


DotNetNuke Forums
 
  Forum  DotNetNuke® Pro...  Repository Modu...  JavaScript Help
Previous Previous
 
Next Next
New Post 5/13/2008 9:31 AM
Unresolved
User is offline Mike Riley
245 posts
9th Ranked


JavaScript Help 

I'm trying to set up some JavaScript in a repository template.html file to hide sections when they are blank.  I'm having some problems.

The sample script I'm embedding is:

<div id="info[ITEMID]">[DESCRIPTION]<hr></div>
<script>
if ('1=2') {
document.getElementById('info[ITEMID]').style.visibility='hidden';
}
</script>

It is hiding the info[ITEMID] div all the time (when it should actually NEVER hide it).

Ultimately, I want to do something like this:

 

<div id="info[ITEMID]">[DESCRIPTION]<hr></div>
<script>
var check[ITEMID]=document.getElementById('info[ITEMID]').innerHTML;
if (check='<hr>') {
document.getElementById('info[ITEMID]').style.visibility='hidden';
}
</script>

I'm hoping someone can offer some insight and see what I'm doing wrong.

 

 
New Post 5/13/2008 10:16 AM
User is offline Brian Dukes
476 posts
www.engagesoftware.com
8th Ranked


Re: JavaScript Help 

Your test expression is a string, not a boolean expression.  In JavaScript, you can compare any expression as a boolean expression, and it will be true if the expression is not null or empty.  So, in your case, your JavaScript is actually just checking is the string value "1=2" exists, which is always true.  If you remove the quotes, it will still be true, because then it will be an assignment, not a comparison, and the result of the assignment is the value assigned (2, in this case).  What you want is something like this:

if (1===2) {
...
}

Note that I'm using a triple (or strict) equals, this makes sure that JavaScript compares the values based on their actual types without conversion.  Otherwise a statement like 1=='1' will be true, even though one side is a number and the other is a string, which is usually not what you want.

Hope that helps,


Brian Dukes
Engage Software
St. Louis, MO
314.966.4000

The leading provider of DotNetNuke support, training and custom module development.
 
New Post 5/13/2008 12:20 PM
User is offline Mike Riley
245 posts
9th Ranked


Re: JavaScript Help 

Thanks, Brian.

A co-worker actually pointed out my mistake to me.  I knew it was going to be something simple.

 
Previous Previous
 
Next Next
  Forum  DotNetNuke® Pro...  Repository Modu...  JavaScript Help
 


Forum Policy

These Discussion Forums are dedicated to the discussion of the DotNetNuke Web Application Framework.

For the benefit of the community and to protect the integrity of the project, please observe the following posting guidelines:

1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DotNetNuke.
2. Discussion or promotion of DotNetNuke product releases under a different brand name are strictly prohibited.
3. No Flaming or Trolling.
4. No Profanity, Racism, or Prejudice.
5. Site Moderators have the final word on approving/removing a thread or post or comment.
6. English language posting only, please.

 


Viva Portals, L.L.C.
Expert module development and graphic design.
www.continure.com
DNN Photo Gallery
DNN Photo Gallery is a truly unique photo management module released January 1st 2006. With DNN Photo Gallery you can REALLY integrate images into your existing portal and make them look like they were designed for your site.
DNN Photo Gallery
Swirlhost Inc.
Affordable DotNetNuke Hosting, Skin Development, Custom Module Development, and DotNetNuke Consulting. We will install your preference of DNN and now host with us and get a free license for the Swirl AJAX Chatroom Module.
www.swirlhost.com

DotNetNuke Corporation   Terms Of Use  Privacy Statement
DotNetNuke®, DNN®, and the DotNetNuke logo are trademarks of DotNetNuke Corporation
Hosted by MaximumASP