• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Compare parentheses in IF condition

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all - I have a JS function to hide few columns from displaying in the web page.Below is the script and I'm very new to JS, so please bare with me for my narrations. The issue is if the value (RHS of ==) to be compared contains any parentheses - that column does not gets hidden. In the below snippet: Plan Title,Organizations (Internal) and Created By are the columns I'm trying to hide from displaying in a web based report, but column Organizations (Internal) is getting displayed. When I alert the contents of gridColumnModel.config[i].header - I can see that Organizations (Internal) is stored as Organizations & # 4 0;Internal & # 4 1; - hence it fails in the IF condition. Right now as a work around I have hard coded the & # 4 0; and & # 4 1; in the RHS of ==. Do we have any encode or decode function so that I could compare it without any hard coding of & # 4 0; etc

>
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So the problem is that you are making decisions based upon the text in the elements, and the text contains encoded HTML entities, correct? (Hard to know for sure from your post.)

My first reaction is to urge you not to do things this way, Display text can change easily from deployment to deployment, or even while developing, so it's a fragile value to be comparing against. Why aren't you using element classes to tag elements for comparisons and processing?
 
Michael Rozar M
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

So the problem is that you are making decisions based upon the text in the elements, and the text contains encoded HTML entities, correct?


That's correct.

Why aren't you using element classes to tag elements for comparisons and processing?


I'm not sure of this method. Can you please show some simple example using Javascript?
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Let's say that you want to get an element to a specific element, say a column header using a <th> element. Rather than searching for it based upon its content, if it has a class name on it, it's really easy to find.

For example: <th class="temperature">Today's Temperature</th>

To find the element (using jQuery, which life is too short not to use): var myColumnHeader = $('.temperature');

By using a class, it's first of all easier; secondly, you are not bound by the vagaries of what the text content could be.
reply
    Bookmark Topic Watch Topic
  • New Topic