Solved

if contains "xxxx" show row

Posted on 2010-11-24
4
384 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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

In this article, we'll look how to sort an Array in JavaScript, including the more advanced techniques of sorting a collection of records either ascending or descending on two or more fields. Basic Sorting of Arrays First, let's look at the …
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
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…

759 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now