Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

if contains "xxxx" show row

Posted on 2010-11-24
4
Medium Priority
?
413 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 2000 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: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
This article discusses how to implement server side field validation and display customized error messages to the client.
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…
Suggested Courses

824 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