Solved

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

Posted on 2012-03-16
3
201 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
CSS Scroll Issue 3 93
My dialog box isnt work, no box displays but text does 8 38
Google Sheets Script 21 58
How can I get this SlideToggle to behave? 6 18
This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
Introduction HyperText Transfer Protocol (http://www.ietf.org/rfc/rfc2616.txt) or "HTTP" is the underpinning of internet communication.  As a teacher of web development I have heard many questions, mostly from my younger students who have come to t…
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…

867 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

22 Experts available now in Live!

Get 1:1 Help Now