Click to See Complete Forum and Search --> : newbie, easy question im sure.
parker
09-08-2003, 10:53 PM
hey everyone, im very new to javascript, but i kind of need to figure sometihng out very quickly. for a site im doing, i have text within a .txt file on my server. I need to display the text in an html file. so far, i've got that to work by copying and pasting some code i found.
My problem is that I want to clean out the "&news=" that appears at the very beginning of the text file, and replace it with nothing. Can anyone please help me?
the html file url:
http://www.erasethedark.com/official/news.html
and the url of the text file:
http://www.erasethedark.com/official/news/txt
document.getElementById("mrq").innerText = oXML.responseText.substring(6, oXML.responseText.length);
simpson97
09-09-2003, 02:36 AM
This works, it uses he javascript replace function.
<script>
text = "&news=blah blah blah etc etc and so on"
newstring = text.replace(/&news=/g,'')
alert(newstring)
</script>
</body>
</html>
Bob
parker
09-09-2003, 08:30 AM
Fang, yours worked, but I'm under the impression that it just shortened the document by 6 characters. Is that correct? Also...part of the formatting of the .txt file is that it will contain "&0D"'s every time there should be a line break, so how do I search through the .txt file and replace every instnace of &0D with <br>? Thanks in advance.
parker
09-09-2003, 08:36 AM
also, I put up a simpler txt file for illustrational purposes.
Basically, what now reads:
blah&0dblah&0DThis is the news body.
& textloaded=OK
I would like to read:
blah
blah
This is the news body.
Thanks again to those who's helped.
-Matt
HosoiRamen
09-09-2003, 10:09 AM
Just use what simpson97 gave you earlier:
<script>
text = "&news=blah blah blah etc etc and so on"
newstring = text.replace(/&news=/g,'')
alert(newstring)
</script>
</body>
</html>
But change is to this:
newstring = text.replace(/&OD=<br>,'')
I think that should work.
parker
09-10-2003, 03:51 PM
OK. Sorry, but neither of those worked. Chances are its me doing something wrong, because I admittedly don't know much about Javascript.
SO HERE'S THE DEAL:
If someone can give me a full solution to the following problem, I'll be sure and credit them on the site, and even send them some money or soemthing.
-----------------------
The Problem
-----------------------
I want to load a text file (news.txt) into an html file, and have it be formatted correctly. Secondly, I want to replace every instance of "&0D" in the text file with a "<br>" in the html file, and lastly, I want to get rid of the "&news=" and the "&textloaded=OK" which appear in the text file.
http://www.erasethedark.com/official/news.html
http://www.erasethedark.com/official/news.txt
Thanks to anyone who can help me.
-Matt
simpson97
09-10-2003, 04:21 PM
Matt,
Are you adverse to using perl or php. I will work up an answer & post it to my site today.
Bob
parker
09-10-2003, 05:04 PM
either of those would be perfect as well. thank you so much.
simpson97
09-10-2003, 06:05 PM
Matt,
check out: http://fpp.co.uk/bobscript/matt.php
The beginning of page is vanilla HTML
we then insert a wee bit of php to get text file, massage &
print it.
We then finish up with vanilla HTML.
I put my email address on example to respond to.
Bob
parker
09-10-2003, 10:35 PM
hey bob, did you get my email?
simpson97
09-10-2003, 11:30 PM
Matt,
email didnt make it but you can use
kmaglobl@mindspring.com
or post a message.
Bob
parker
09-11-2003, 12:06 AM
hey bob,
the script seems to work wonderfully on your server. So, if you could somehow send me the php file that would be great. my email is matt@deathbystarlight.com. Thanks a ton.
parker
09-11-2003, 04:21 PM
thanks bob, i'll keep you in mind for scritping hobs, as well as mention you in the news. any url you'd like me to site for you?