![]() |
RegEx matching in Javascript?
Lets say I have some code....
Code:
<img src="dir/cas.jpg"><img src="dir/ast.jpg"> Code:
matches[0] = cas Code:
output = cas,ast --------------- Added [DATE]1248292603[/DATE] at [TIME]1248292603[/TIME] --------------- revised my requirements... --------------- Added [DATE]1248315264[/DATE] at [TIME]1248315264[/TIME] --------------- So no one has any ideas for me? This is the last thing I need for an AJAX script I am working on. |
Code:
<script type="text/javascript"> |
This works great... But I am having one issue incorporating this with Ajax...
This is the text field to be edited... Code:
<div class="editUse"><img src="ranking/usage/amy.gif"></div> Code:
function editBox_use(actual) { ($input is the new value where "amy" once was, lets say for now it is "cas") Code:
function update_score($input) Code:
<div class="editUse"><img src="ranking/usage/cas.gif"></div> However, now a new issue comes up... THEORETICALLY, if I click on the div AGAIN (without refresshing the page), it should return the text box filled out with the word "cas". It doesn't instead it gives me a blank text box. If I refresh the page, it works fine, but if I don't (which is the purpose of AJAX), the regex script fails. Is there something wrong with the way the new HTML is echoed out that makes it fail the matching? |
w3schools covers this nicely http://www.w3schools.com/jsref/jsref_obj_regexp.asp
|
Where do you insert the returned HTML? Obviously when AJAX is returning the response and you're inserting that response it's not doing so correctly, that or the original HTML is stored in a variable and not grabbed each time it's ran.
I'd probably have to see the page with the JS to get the full scope and identify the issue. |
Okay... I have set up a test page... (IE only)
http://www.8wayrun.com/test.html It uses 2 other files... the test.JS file (link on the page above), and a test.PHP file: contents below: Code:
<?php If you to that page, you will understand my problem more. If you click on the image bar, it will return the following text: "cas,sig,hil,cer,xia". You can then change the text, for instance, type in "tir,tal,tak". Instead of those 5 previous images, you will get 3 different images. That is working as intended... Now, click on the image bar again, without refreshing the page. Instead of it returning "tir,tal,tak", it returns an empty text box. This is my problem. |
Change:
Code:
while (code.match(/(<img src="\w+\/usage\/(\w+?)\.gif">)/i)) { Code:
while (code.match(/(<img src=".+?\/usage\/(\w+?)\.gif">)/i)) { |
Wow... that really fixed it... thanks so much...
--------------- Added [DATE]1248471182[/DATE] at [TIME]1248471182[/TIME] --------------- I'm having problems with this code... Code:
function fetch_usage(code) { |
That code you posted is the old function, did you mean the new one with the edit I specified above?
|
I figured out the problem... this line does not work in firefox...
Code:
code = code.replace(RegExp.$1, '', code); Code:
code = code.replace(RegExp.$1, ''); This is what I used this for: http://www.8wayrun.com/video.php?do=...s&videoid=1045 (watch the video) |
All times are GMT. The time now is 11:39 PM. |
Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|