Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeDNN Open Source...DNN Open Source...Module ForumsModule ForumsRepositoryRepositoryJavaScript HelpJavaScript Help
Previous
 
Next
New Post
5/13/2008 11:31 AM
 

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 12:16 PM
 

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
866-907-4002
DNN partner specializing in custom, enterprise DNN development.
 
New Post
5/13/2008 2:20 PM
 

Thanks, Brian.

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

 
Previous
 
Next
HomeHomeDNN Open Source...DNN Open Source...Module ForumsModule ForumsRepositoryRepositoryJavaScript HelpJavaScript Help


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, 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 DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out