Solved

if contains "xxxx" show row

Posted on 2010-11-24
4
390 Views
Last Modified: 2012-08-13
I am using the below code to show or hide a table row based a list menu value being 1 or 11.

<script language="javascript">
      $("document").ready(function() {
             $('#ink_brand_id').bind('change',function(){
                  if( this.selectedIndex > -1  && this.options[this.selectedIndex].value==1 || this.options[this.selectedIndex].value==11)
                        $(".captionRow").show();
                  else
                        $(".captionRow").hide();
            });
            $('#ink_brand_id').change();
      });
</script>

How do I change it show the table row shows if the list menu contains the words "Colorific" or "Elements"?
0
Comment
Question by:petewinter
  • 3
4 Comments
 
LVL 10

Expert Comment

by:hosneylk
ID: 34203847

if( this.selectedIndex > -1  && this.options[this.selectedIndex].value.indexOf('Colorific') >= 0 || this.options[this.selectedIndex].value.indexOf('Elements') >= 0)

Open in new window

0
 
LVL 10

Accepted Solution

by:
hosneylk earned 500 total points
ID: 34203853
sorry. value should be text.
if( this.selectedIndex > -1  && this.options[this.selectedIndex].text.indexOf('Colorific') >= 0 || this.options[this.selectedIndex].text.indexOf('Elements') >= 0)

Open in new window

0
 
LVL 10

Expert Comment

by:hosneylk
ID: 34203900
you can also do this
if( this.selectedIndex > -1  && this.options[this.selectedIndex].text.search(/Colorific|Elements/) >= 0)

Open in new window

0
 

Author Closing Comment

by:petewinter
ID: 34204017
Perfect. Many thanks
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question