Solved

search for string on page and store it in a variable.

Posted on 2012-03-16
3
200 Views
Last Modified: 2012-03-16
Can you help me  search for a string on a web page and then remove the beginning of the string and then create a variable with the result value using javascript?

So I have a string on the page that begins with "GHID:" then 10 digits.  

How can I search the page for the string "GHID:********" (* - wildcard representing the 10 digits)

Then remove the "GHID:" and create a variable equal to just the 10 remaining numbers?
0
Comment
Question by:ForLoop5
  • 2
3 Comments
 
LVL 82

Expert Comment

by:leakim971
ID: 37731463
>Can you help me  search for a string on MY OWN web page

please confirm
0
 
LVL 1

Author Comment

by:ForLoop5
ID: 37731474
yes it is on my own web page.
0
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
ID: 37731493
so with jQuery :
$.get("path/to/your/page.html", function( pageHTML ) {
  var your_10_digits = pageHTML.substr( pageHTML.indexOf("GHID:"), 10);
});

Open in new window


If it don't work, please provide a page to see your page and the code provided
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
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…

706 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

19 Experts available now in Live!

Get 1:1 Help Now