Hi I'm a very n00bish, nay, pathetic excuse for a coder and am trying to make a "quote for the day" in jscript that pulls files from a .txt file. Here's what I've got in the main page Code: <script> <!-- var today_obj=new Date() var today_date=today_obj.getDate() var tips= "tips.txt" document.write(tips[today_date]) //--> </script> and then in the same folder I have tips.txt containing this Code: tips[1]='Tip 1 goes here' tips[2]='Tip 2 goes here' tips[3]='Tip 3 goes here' tips[4]='Tip 4 goes here' tips[5]='Tip 5 goes here' tips[6]='Tip 6 goes here' tips[7]='Tip 7 goes here' tips[8]='Tip 8 goes here' etc I'm not too good with javascript and was hoping some1 could point me in the right direction?! Thanks in advance
I would recomened trying not to use jscript, as its a requirment on the (l)user to have it. If you have PHP/ASP/CGI then that would be better. But if you do it that way, you're stacking an array but its not going to be in the same format as date. Also the client has to load the whole txt file, not good if u make it big. But if its just small, then simply include it in the HTML! if ur using it in lotsa HTML pages, then make the whole code in a .js file, and just include that. If u want clarification of any of those options just ask
Thanks . I would use PHP if the 'customer' wasn't using 0catch *sigh*, and I wanted it to be easily edited from anywhere, hence the inclusion of a .txt instead of inside the page. I think what I'll do is try and switch the host to a php one, as I actually know SOME php lol. Thanks for the advice.
No worries, using PHP would be the better option but its still possible to have the easy edit file if you just include the .js file so you would have your quotes at the top quotes[date-its-for]='Blergh is the new Ergh!' quotes[day-after]='Ergh is back in fassion' \* code starts here, don't edit below */ quotecontainer.innerHTML= ........ so its is easyily possible, just not all broswers would support it. sorry if i didn't make that clear in the first post.