473,388 Members | 1,342 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

How to get an exact match whilst searching inside a string.

Ok i am fudging a legacy CRM system and i need to hide a button on the script using client side javascript.

I am trying to hide a button on the screen based on the URL containing the word SendEmail by looking inside the HREF tag and if there is a match... hide it!

The code works fine apart from there is another button with exactly the same markup, etc but the link shows SendEmailUsingOutlook (please see html below).

So i need to find the exact match of SendEmail and exclude SendEmailUsingOutlook.

P.S. I can't modify any of the HTML, CSS, etc this is generated by the system.

i am currently using:

Expand|Select|Wrap|Line Numbers
  1. window.attachEvent("onload",hideElement); 
  2.  
  3. function hideElement() 
  4. for(i=0;i<document.all.length;i++) 
  5. {
  6. if(document.all[i].tagName=='A') 
  7. {
  8. if(document.all[i].href.search(/SubmitEmail/i)>-1) 
  9. {
  10. document.all[i].style.visibility = hidden;
  11. }
  12. }
  13. }
  14. }
  15.  
The html buttons as generated from the CRM system:
Expand|Select|Wrap|Line Numbers
  1. <A CLASS=ButtonItem HREF="javascript:try{if(SubmitEmail            (true)==true) self.document.EntryForm.submit();}catch(err){alert('The path to local file is incorrect, please use Browse button to select file.')}"><IMG SRC="/CRM/Themes/img/color/Buttons/SendEmail.gif" BORDER=0 ALIGN=MIDDLE></A>
  2. <A CLASS=ButtonItem HREF="javascript:try{if(SubmitEmailUsingOutlook(true)==true) self.document.EntryForm.submit();}catch(err){alert('The path to local file is incorrect, please use Browse button to select file.')}"><IMG SRC="/CRM/Themes/img/color/Buttons/SendOutlookEmail.gif" BORDER=0 ALIGN=MIDDLE></A></TD>
  3.  
Sep 30 '10 #1
2 1784
RamananKalirajan
608 512MB
use .indexOf() to search for some characters in a String.

Ex:
Expand|Select|Wrap|Line Numbers
  1.   var str = "This is a Search String";
  2.   var ind = str.indexOf("Search");
the ind will be -1 if the search string is no there. If it is there it will return starting index of the character sequence.

Thanks and Regards
Ramanan Kalirajan
Oct 1 '10 #2
acoder
16,027 Expert Mod 8TB
That wouldn't work as it'd still find the longer string. For a very simple solution, you could look for "SendEmail " (with a space).
Oct 1 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Steve G | last post by:
Steve G Feb 1, 1:12 pm show options From: "Steve G" <sgr...@computicle.com> - Find messages by this author Date: Tue, 01 Feb 2005 13:12:42 -0800 Local: Tues, Feb 1 2005 1:12 pm Subject:...
2
by: Andy | last post by:
Hi... i'm trying to understand the concept of function name overloading in c++. to understand the resolving system it's important to understand the diffrent levels of typecasting (exact match,...
2
by: Larry | last post by:
I have the following code attached to a search button on a form that runs a query. It works great, except that the search for Last Name only returns exact matches. It is even case sensitive....
9
by: a | last post by:
I need to write a regular expression to match a quoted string in which the double quote character itself is represented by 2 double quotes. For example: "beginning ""nested quoted string"" end"...
2
by: perlnoob | last post by:
Hello, I am noob to Perl Programming. Here's what I need to do. I need to match a string value from a file and upon matching the value, I need the remainder of the file to be printed to an output....
2
by: Wayne Shu | last post by:
Hi everyone. In the following program, foo is an ambiguous call. #include <iostream> using namespace std; void foo(int *); void foo(int (&));
2
by: Slippy27 | last post by:
I'm trying to modify a find/replace script which iterates through a file A and makes replacements defined in a csv file B. My original goal was to change any line in file A containing a search string...
6
by: Mr.SpOOn | last post by:
Hi, I'd like to use regular expressions to parse a string and accept only valid strings. What I mean is the possibility to check if the whole string matches the regex. So if I have: I can...
0
by: Lie Ryan | last post by:
On Sun, 26 Oct 2008 17:51:29 +0100, Mr.SpOOn wrote: re.compile('a*b*$') $ matches the end of a string, or in MULTILINE mode, the end of a line (right before newline) Symmetrically, ^...
5
dmjpro
by: dmjpro | last post by:
String input = "Mozila"; System.out.println(Pattern.matches("^Moz")); //returns false System.out.println(Pattern.matches("^Moz.+")); //returns true Can't i match part of the string using Reg...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.