Solved

if contains "xxxx" show row

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
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…

821 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