Solved

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

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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Introduction Got endorsements from your clients?  Great!  There is almost nothing better than word-of-mouth advertising.  But how can you do that on the internet?  Sure you can make a page for endorsement quotations and list them all, but who is …
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
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…

808 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