skyline — 2010-03-26T12:29:29-04:00 — #1
Can anyone help me with the js to find and replace any prices within the innerHTML?
i wan't to find all instances of these and replace them with alternative strings
johnny_dipin — 2010-03-26T13:03:42-04:00 — #2
<h1 id="header">Old Header</h1>
<a href="#" onclick="change()">click me</a>
<p>"Old Header" was changed to "New Header"</p>
This should show how you can change the value if you can access the element. In your case is there a way you can get prices. Does this help?
skyline — 2010-03-26T13:08:05-04:00 — #3
Thanks for the reply.
Thing is i'm looking for the way to find all of the prices on the page so they can then be changed. A regex of some description i guess?
johnny_dipin — 2010-03-26T14:41:49-04:00 — #4
Probably. I dont know. But here is a simple sample that changes the prices if you know the value atleast.
var bodyText = document.body.innerHTML;
<button onclick="searchPage()">Click me</button>
skyline — 2010-03-27T03:49:48-04:00 — #5
Mmm unfortunately the prices are unknown! Anyone good with js regex?
paul_wilkins — 2010-03-27T06:32:02-04:00 — #6
What are the currency formats you expect to be dealt with?
Is it only euro, dollar, pound and yen, in the formats that you provided, that you want to match?
I'm no expert on regular expressions, but I think you might be after something like this:
skyline — 2010-03-27T08:27:01-04:00 — #7
Yes that seems to find them!
Now how would i go about replacing each of the occurences with an ajax response?
paul_wilkins — 2010-03-27T14:37:29-04:00 — #8