Solved

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

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
html Uncheck Checkbox 2 25
VBScript on Html 15 47
HowTo set a global variable in javascript or jQuery 4 21
Button on Table, name table1 not working 4 19
Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
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…

765 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