Solved

how do you check for two parameters with jquery

Posted on 2014-11-24
5
76 Views
Last Modified: 2014-11-24
Hi,

I'm trying to check the url for either "ID_xxxxx" or "CON_ID_xxxxxx"

The "x" is either a five or six figure number

This is what I have so far. Thanks for the help!

<script type="text/javascript">
        $(document).ready(function () {
            if(window.location.href.indexOf("ID" || "CON") > -1)
            {
                 alert("found it");
            }
			
        });
    </script>

Open in new window

0
Comment
Question by:smfmetro10
  • 2
  • 2
5 Comments
 
LVL 51

Expert Comment

by:HainKurt
ID: 40463040
if(window.location.href.indexOf("ID" || "CON") > -1)

>>>

if ((window.location.href.indexOf("ID") > -1) || (window.location.href.indexOf("CON") > -1))
0
 
LVL 58

Expert Comment

by:Gary
ID: 40463045
I assume you want the xxxxx part so what's an example url

(or maybe not)
0
 

Author Comment

by:smfmetro10
ID: 40463057
Ah - it would either be "ID_12345" or" CON_ID_123456"
0
 
LVL 51

Accepted Solution

by:
HainKurt earned 500 total points
ID: 40463126
here it is if you need XXXXXX:
var url = window.location.href;
if (url.indexOf("ID_")>-1 || url.indexOf("CON_ID_") > -1)
{
  alert("found it");
  var num = url.replace("CON_ID_","").replace("ID_","");
  alert(num);
}

Open in new window

0
 

Author Closing Comment

by:smfmetro10
ID: 40463179
Thanks!
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

When you need to keep track of a simple list of numbers or strings, the Array object is your most direct tool.  As we saw in my earlier EE Article (http://www.experts-exchange.com/A_3488.html), typical array handling might look like this: (CODE) B…
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 …
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…

747 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

12 Experts available now in Live!

Get 1:1 Help Now