JavaScript - Javascript For Daily Affirmation (365 Days) From Array In External Text File
I have a Java Script that displays a Daily Affirmation on a webpage from an array of 365 Affirmations within the same html webpage file. This makes the html file size way too large. So I would like for the java script to read the array from an external text file on the same website server.
Please provide me the Code to insert within my script which will read the array from an external text file - and also the format that the array of 365 lines must be typed into the external text file. I am not a Javascript Programmer - and know nothing about Javascript, so please write your reply at my (lack of) knowledge Level. Thank you in advance! Here is the code I am using. <script language=javascript> <!-- Date.prototype.getDOY = function() {var onejan = new Date(this.getFullYear(),0,1); return Math.ceil((this - onejan) / 86400000);} var today = new Date(); var DOY = today.getDOY(); var HL=new Array() //Configure the following array to hold the 365 HLs for each day of the year HL[1]='HL 1 goes here' HL[2]='HL 2 goes here' HL[3]='HL 3 goes here' // Jump to Day 224 of the year for this example only HL[224]='I am surrounding myself with positive and supportive people. When I nurture relationships that give me energy and enjoyment, I mirror my beliefs that I deserve such gifts.' HL[225]='Today I affirm my own worth and value, and discover that the world agrees with me.' HL[226]='I am sowing seeds based on a healthy belief in my own self-worth. My life is flourishing with growing love, contentment, and exciting possibilities.' HL[227]='HL 227 goes here' HL[228]='HL 228 goes here' // Jump to last HL for Day 365 of year - for this example only HL[365]='HL 365 goes here' document.write(HL[DOY]) //--> </script> Similar TutorialsI work at a bar in Louisiana and have been put in charge of the website. Every day (Sun-Sat) we update the main page with who is bartending that night, along with a few other edits. I don't come into the office until 2pm, Mon-Fri. I would really prefer if the website could be updated 'automatically' at like, 4am or something, every day. Instead of me struggling to figure out how I'll update it on weekends. I have to use FrontPage, so I'm limited in the types of codes I can use. But Javascript seems to work well. What I'm thinking is have an 'updates' folder with pages labeled either by weekday (sunday.html monday.html tuesday.html, etc) or by date (072410.html, 072510.html, etc). Then the main page having some code that pulls from those files. (I'd prefer the weekday setup if I have the option) Since the bar doesn't close until 2am most days, I'd rather not have it change over at exactly midnight, but I'm willing to work with that if it means I know it's being updated every day regularly. Hi, I have an external JS file with an array of menu links called (menu.js). The code is shown below: Code: <script> var menuItem = new Array(); menuItem[0]="index.html"; menuItem[1]="welcome_home/index.html"; menuItem[2]="key_resources/index.html"; menuItem[3]="deployment_assistance/index.html"; menuItem[4]="benefits/index.html"; menuItem[5]="services/index.html"; menuItem[6]="counties/index.html"; menuItem[7]="transitional_help/index.html"; menuItem[8]="women_vets/index.html"; menuItem[9]="iowa_heroes/index.html"; menuItem[10]="http://www.iowava.org/vetcemetery/"; menuItem[11]="http://ivh.iowa.gov"; menuItem[12]="../forms/index.html"; menuItem[13]="https://va.iowa.gov/reselig/"; menuItem[14]="links2/index.html"; menuItem[15]="Whats_New/index.html"; menuItem[16]="contact_us/index.html"; function Page(which){ location.href = menuItem[which]; } </script> I have called the javascript in my websites main page (index.html), but it does not work. The html code is shown below: Code: <script type ="text/javascript" src="menu.js"></script> <a href="javascript:void(0);" onclick="Page(0);">Home</a> <a href="javascript:void(0);" onclick="Page(1);">Welcome Home</a> <a href="javascript:void(0);" onclick="Page(2);">Key Resources</a> The javascript for the array of menu links works when it is inserted directly within the html file, but when it remains external and is called in index.html it does not work. I am not sure why this is the case. Could anyone give some pointers? Thanks, -Mike I'm having major pains trying to figure this out. I'm kind of new to Javascript, I need to open a text file from an external server, store each line in an array, then search that array for a certain word (HIGH), and if it exists then write something to the webpage, and if not, write something else. Here is what I have so far: Code: <html> <head> <title>Test</title> <script> <!-- function test(x) { if (wxd1txt.readyState === 4 && wxd1txt.status === 200) { // Makes sure the document is ready to parse and Makes sure it's found the file. var wxd1text = wxd1txt.responseText; var wxd1array = wxd1txt.responseText.split("\n"); // Will separate each line into an array var wxd1high = wxd1array.toString(); //Converting the String content to String //var highsearchreg = new RegExp("HIGH"); //var wxd1high = wxd1array[x].search(highsearchreg); document.write(wxd1high); if (wxd1high.search("HIGH") >= 0){ document.write("HIGH RISK");} else { document.write("NO RISK");} } } //--> </script> </head> <body> Hi! <script> <!-- var Today = new Date(); var ThisDay = Today.getDate(); var ThisMonth = Today.getMonth()+1; var ThisYear = Today.getYear(); var Hour = Today.getHours(); var Day2 = Today.getDate()+1; var Day3 = Today.getDate()+2; if (navigator.appName != "Microsoft Internet Explorer") { ThisYear = ThisYear + 1900;} if (ThisMonth < 10) { ThisMonth = "0" + ThisMonth;} if (ThisDay < 10) { ThisDay = "0" + ThisDay;} if (Hour == 2 || Hour == 22 || Hour == 23 || Hour == 0 || Hour == 1) { var wxHourd1 = 0600} else if (Hour >= 3 && Hour <= 10) { var wxHourd1 = 1300;} else if (Hour >= 11 && Hour <= 13) { var wxHourd1 = 1630;} else if (Hour >= 14 && Hour <= 16) { var wxHourd1 = 2000;} else if (Hour >= 17 && Hour <= 21) { var wxHourd1 = 0100;} //var wxurld1 = "http://www.spc.noaa.gov/products/outlook/archive/"+ThisYear+"/KWNSPTSDY1_"+ThisYear+""+ThisMonth+""+ThisDay+""+wxHourd1+".txt"; var wxurld1 = "http://www.spc.noaa.gov/products/outlook/archive/2010/KWNSPTSDY1_201005101300.txt" //(High risk day for testing) //document.write(wxurld1); //Use this to verify this section is working if (window.XMLHttpRequest) { wxd1txt=new XMLHttpRequest(); } else // IE 5/6 { wxd1txt=new ActiveXObject("Microsoft.XMLHTTP"); } wxd1txt.open("GET", wxurld1, true); wxd1txt.onreadystatechange = test(); // --> </script> </body> </html> When added to a webpage, nothing shows up except the "Hi!" and there are no errors in the Javascript Console in Google Chrome. Is this possible with Javascript, and if so, what am I doing wrong or not doing? Also, I have 2 URLs, one is a text file that has the HIGH text I want for an example, the other is the current file, which shouldn't have HIGH in it (unless the weather in the US turns really bad) Hey guys, I'm writing a script and I've encountered a problem.. I have a txt file with many words, each word in a different line. For example: the file words.txt contains: word1 word2 word3 word4 word5 I need to load the content of the file into a variable in my script. I prefer that all the words will be in the same variable with line breaks, but if you'll figure out a way to put it in an array, it's ok too. I really don't know how to do it, and I tried to google but didn't understand.. By the way, I don't want to change the txt file to js file, I need it to remain txt.. Can anybody help me with that? Thanks Alot, Ran First, this is my first time coding anything seriously. I've only dabbled here and there, but no more. Any and all tips are appreciated. I have a program that's designed to calculate total enemy health. Its does this by taking user input on the level and enemy name. The enemy level input determines the base health stat. The enemy name determines the percent multiplier. This all runs on an onClick() event. I originally had this all in my <head> in my html code. It ended up being more code than I expected. So i made it an external javascript file. I did remove the <script></script> tags, I believe I have the file properly linked using the src attribute. I'm at my wits end. This is my second day of trying. So here is the javascript code. Code: // JavaScript Document var series; var index; var indexValue; var base; var distance; var sequence; var enemyLv; var enemyPct; var enemyHp; var vOneFive; var wrongAlert; var enemyList; var enemyName; var enemyInput; var enemyLevel; var a = enemyLEVEL(); var b = enemyPCT(); var totalHp = a * b; //calculates enemyHp and enemyPct function calc(enemyHp, enemyPct) { a = enemyLEVEL(); b = enemyPCT(); totalHp = a * b; if(a && b !== -1){ document.getElementById('enemyTotalHp').innerHTML = totalHp; } else{ alert(wrong); } } //determines base stat for enemyHp function enemyLEVEL(enemyHp){ enemyLv = document.getElementById('enemyLevel').value; var enemyLvValue = enemyLv * 1; wrongAlert = "BURGA!"; //determines which HP sequence to run if(enemyLvValue <= 5){ enemyLv = document.getElementById('enemyLevel').value; enemyLvValue = enemyLv * 1; series = '12345'; index = series.indexOf(enemyLvValue); indexValue = index * 1; base = 70; distance = 13; sequence = base + (indexValue * distance); enemyHp = sequence; return enemyHp; } else if(enemyLvValue <= 10){ enemyLv = document.getElementById('enemyLevel').value; enemyLvValue = enemyLv * 1; series = '5678910'; index = series.indexOf(enemyLvValue); indexValue = index * 1; base = 122; distance = 24.8; sequence = base + (indexValue) * distance; enemyHp = sequence; return enemyHp; } else if(enemyLvValue <= 15){ enemyLv = document.getElementById('enemyLevel').value; enemyLvValue = enemyLv * 1; series = '101112131415'; index = series.indexOf(enemyLvValue); indexValue = index * 1; base = 246; distance = 50; sequence = base + ((indexValue)/2) * distance; enemyHp = sequence; return enemyHp; } else if(enemyLvValue <= 20){ enemyLv = document.getElementById('enemyLevel').value; enemyLvValue = enemyLv * 1; series = '151617181920'; index = series.indexOf(enemyLvValue); indexValue = index * 1; base = 496; distance = 129.8; sequence = base + ((indexValue)/2) * distance; enemyHp = sequence; return enemyHp; } else if(enemyLvValue <= 45){ enemyLv = document.getElementById('enemyLevel').value; enemyLvValue = enemyLv * 1; series = '2021222324252627282930313233343536373839404142434445'; index = series.indexOf(enemyLvValue); indexValue = index * 1; base = 1145; distance = 120; sequence = base + ((indexValue)/2) * distance; enemyHp = sequence; return enemyHp; } else if(enemyLvValue <= 50){ enemyLv = document.getElementById('enemyLevel').value; enemyLvValue = enemyLv * 1; series = '454647484950'; index = series.indexOf(enemyLvValue); indexValue = index * 1; base = 4145; distance = 133; sequence = base + ((indexValue)/2) * distance; enemyHp = sequence; return enemyHp; } else if (enemyLvValue <= 75){ enemyLv = document.getElementById('enemyLevel').value; enemyLvValue = enemyLv * 1; series = '5051525354555657585960616263646566676869707172737475'; index = series.lastIndexOf(enemyLvValue); indexValue = index * 1; base = 4810; distance = 75; sequence = base + ((indexValue)/2) * distance; enemyHp = sequence; return enemyHp; } else if (enemyLvValue <= 99){ enemyLv = document.getElementById('enemyLevel').value; enemyLvValue = enemyLv * 1; series = '75767778798081828384858687888990919293949596979899'; index = series.lastIndexOf(enemyLvValue); indexValue = index * 1; base = 6685; distance = 70; sequence = base + ((indexValue)/2) * distance; enemyHp = sequence; return enemyHp; } else if(enemyLvValue <= 110){ enemyLv = document.getElementById('enemyLevel').value; enemyLvValue = enemyLv * 1; series ='100101102103104105106107108109110'; index = series.indexOf(enemyLvValue); indexValue = index * 1; base = 8435; distance = 70; sequence = base + ((indexValue)/3) * distance; enemyHp = sequence; return enemyHp; } else if(enemyLvValue <= 170){ enemyLv = document.getElementById('enemyLevel').value; enemyLvValue = enemyLv * 1; series ='110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170'; index = series.indexOf(enemyLvValue); indexValue = index * 1; base = 9130; distance = 70; sequence = base + ((indexValue)/3) * distance; enemyHp = sequence; return enemyHp; } else{ alert(wrongAlert); } } //determines enemyPct variable function enemyPCT(enemyPct){ enemyInput = document.getElementById('enemyUser').value; enemyName = enemyInput; enemyList = new Array(); enemyList[1] = "Vahra Go Vahra Delsaban Golmoro Goshin Fulyen Curtz SEED-Guardian (Tw) Special Ops (Assault) Bysha type-Koh21 Bysha type-Otsu32 Gohma Dilla Gohma Methna GSM-05 Seeker GSM-05B Bomalta GSM-05M Tirentos YG-01K BUGGE YG01U BUGGES YG-01Z BUG Deljaban Orcdillan Sendillan";//100% hp // enemyList[2] = "Ageeta Sageeta Rogue Wikko Special Ops (Vobis)"; //60% hp // enemyList[3] = "Pannon Bel Pannon Galdeen Kudetob Nava Ludda Naval Zoona Shagreece Lapucha Polty Badia Go Bajilla"; //70% hp // enemyList[4] = "Armed Servant (Obme) Armed Servant (Ozuna) Distova Volfu Olgohmon Bul Buna";//90% hp // enemyList[5] = "Koltova Kakwane Ollaka Rappy Polec AMF Heavy Infantry Armed Servant (Basta) SEED-Guardian (Kn) Delp Slami";//130%hp // enemyList[6] = "Booma Go Booma Jigo Booma Jishagara Vanda Vanda Merha Vanda Orga Rogue (Ogg) SEED-Guardian (Sa)";//150%hp // enemyList[7] = "Rogue (Jasse) Rogue Mazz Special Ops (Kanohne) Special Ops (Solda)";//180%hp // enemyList[8] = "Komazli Bead Groode Dilla Griena Grinna Bete C";//200%hp // enemyList[9] = "Bal Soza Gaozoran";//230%hp; // enemyList[10] = "Shinowa Hidoki" ;//250% hp // enemyList[11] = "Jaggo Jaggo Acte Jaggo Amure Jaggo Sonichi Zamvapas Galvapas Do Vol No Vol";//260% hp // enemyList[12] = "Mizura Gainozeros Grass Assassin Ubakrada Rappy Rappy Amure Rappy Latan Rappy Noel Rappy Paska";//300% hp // enemyList[13] = "Kamatoze Bafal Bragga";//320% hp // enemyList[14] = "Jarba Polavohra Hiru Vol Delnadian SEED-Ardite Zasharogan Lutus Jigga Orgdus Svaltus";//350% hp // enemyList[15] = "Tengohg Bil De Melan Bil De Vear Drua Gohra Kog Nadd Dilnazen Jusnagun SEED-Argine SEED-Vance SEED-Vitace Ryugtass";//400% hp // enemyList[16] = "Carriguine SEED-Venas";//450% hp // enemyList[17] = "Rappy Gugg Renvolt Magashi Grinna Bete S";//500% hp // enemyList[18] = "Rappy Igg";//550% hp // enemyList[19] = "Darbelan Alfort Tylor";//600% hp // enemyList[20] = "Kagajibari";//630% hp // enemyList[21] = "Gol Dova";//650% hp // enemyList[22] = "Zoal Goug"; //700% hp // enemyList[23] = "De Rol Le";//1000% hp // enemyList[24] = "SEED-Magashi";//1100% hp // enemyList[25] = "Alterazgohg Onmagoug";//1350% hp // enemyList[26] = "Adahna Dimmagolus Dark Falz";//1450% hp // enemyList[27] = "De Ragan Magas Maggahna";//1500% hp // enemyList[28] = "Dulk Fakis Mother Brain";//1650% hp // enemyList[29] = "De Ragnus";//1720% hp var one = enemyList[1]; var two = enemyList[2]; var three = enemyList[3]; var four = enemyList[4]; var five = enemyList[5]; var six = enemyList[6]; var seven = enemyList[7]; var eight = enemyList[8]; var nine = enemyList[9]; var ten = enemyList[10]; var eleven = enemyList[11]; var twelve = enemyList[12]; var thirteen = enemyList[13]; var fourteen = enemyList[14]; var fifteen = enemyList[15]; var sixteen = enemyList[16]; var seventeen = enemyList[17]; var eighteen = enemyList[18]; var nineteen = enemyList[19]; var twenty = enemyList[20]; var twentyone = enemyList[21]; var twentytwo = enemyList[22]; var twentythree = enemyList[23]; var twentyfour = enemyList[24]; var twentyfive = enemyList[25]; var twentysix = enemyList[26]; var twentyseven = enemyList[27]; var twentyeight = enemyList[28]; var twentynine = enemyList[29]; // var indexOne = one.indexOf(enemyName); var indexTwo = two.indexOf(enemyName); var indexThree = three.indexOf(enemyName); var indexFour = four.indexOf(enemyName); var indexFive = five.indexOf(enemyName); var indexSix = six.indexOf(enemyName); var indexSeven = seven.indexOf(enemyName); var indexEight = eight.indexOf(enemyName); var indexNine = nine.indexOf(enemyName); var indexTen = ten.indexOf(enemyName); var indexEleven = eleven.indexOf(enemyName); var indexTwelve = twelve.indexOf(enemyName); var indexThirteen = thirteen.indexOf(enemyName); var indexFourteen = fourteen.indexOf(enemyName); var indexFifteen = fifteen.indexOf(enemyName); var indexSixteen = sixteen.indexOf(enemyName); var indexSeventeen = seventeen.indexOf(enemyName); var indexEighteen = eighteen.indexOf(enemyName); var indexNineteen = nineteen.indexOf(enemyName); var indexTwenty = twenty.indexOf(enemyName); var indexTwentyOne = twentyone.indexOf(enemyName); var indexTwentyTwo = twentytwo.indexOf(enemyName); var indexTwentyThree = twentythree.indexOf(enemyName); var indexTwentyFour = twentyfour.indexOf(enemyName); var indexTwentyFive = twentyfive.indexOf(enemyName); var indexTwentySix = twentysix.indexOf(enemyName); var indexTwentySeven = twentyseven.indexOf(enemyName); var indexTwentyEight = twentyeight.indexOf(enemyName); var indexTwentyNine = twentynine.indexOf(enemyName); // var test = "YOU CAN DO IT LITTLE NICKY! BITE HIS ****ING HEAD OFF!"; // if(indexOne != -1){ var enemyPctValue = 1; enemyPct = enemyPctValue; return enemyPct; } // else if(indexTwo != -1){ var enemyPctValue = 0.6; enemyPct = enemyPctValue; return enemyPct; } // else if(indexThree != -1){ var enemyPctValue = 0.7; enemyPct = enemyPctValue; return enemyPct; } // else if(indexFour != -1){ var enemyPctValue = 0.9; enemyPct = enemyPctValue; return enemyPct; } // else if(indexFive != -1){ var enemyPctValue = 1.3; enemyPct = enemyPctValue; return enemyPct; } // else if(indexSix != -1){ var enemyPctValue = 1.5; enemyPct = enemyPctValue; return enemyPct; } else if(indexSeven != -1){ var enemyPctValue = 1.8; enemyPct = enemyPctValue; return enemyPct; } else if(indexEight != -1){ var enemyPctValue = 2; enemyPct = enemyPctValue; return enemyPct; } else if(indexNine != -1){ var enemyPctValue = 2.3; enemyPct = enemyPctValue; return enemyPct; } else if(indexTen != -1){ var enemyPctValue = 2.5; enemyPct = enemyPctValue; return enemyPct; } else if(indexEleven != -1){ var enemyPctValue = 2.6; enemyPct = enemyPctValue; return enemyPct; } else if(indexTwelve != -1){ var enemyPctValue = 3; enemyPct = enemyPctValue; return enemyPct; } else if(indexThirteen != -1){ var enemyPctValue = 3.2; enemyPct = enemyPctValue; return enemyPct; } else if(indexFourteen != -1){ var enemyPctValue = 3.5; enemyPct = enemyPctValue; return enemyPct; } else if (indexFifteen != -1){ var enemyPctValue = 4; enemyPct = enemyPctValue; return enemyPct; } else if(indexSixteen != -1){ var enemyPctValue = 4.5; enemyPct = enemyPctValue; return enemyPct; } else if(indexSeventeen != -1){ var enemyPctValue = 5; enemyPct = enemyPctValue; return enemyPct; } else if(indexEighteen != -1){ var enemyPctValue = 5.5; enemyPct = enemyPctValue; return enemyPct; } else if(indexNineteen != -1){ var enemyPctValue = 6; enemyPct = enemyPctValue; return enemyPct; } else if(indexTwenty != -1){ var enemyPctValue = 6.3; enemyPct = enemyPctValue; return enemyPct; } else if(indexTwentyOne != -1){ var enemyPctValue = 6.5; enemyPct = enemyPctValue; return enemyPct; } else if(indexTwentyTwo != -1){ var enemyPctValue = 7; enemyPct = enemyPctValue; return enemyPct; } else if(indexTwentyThree != -1){ var enemyPctValue = 10; enemyPct = enemyPctValue; return enemyPct; } else if(indexTwentyFour != -1){ var enemyPctValue = 11; enemyPct = enemyPctValue; return enemyPct; } else if(indexTwentyFive != -1){ var enemyPctValue = 13.5; enemyPct = enemyPctValue; return enemyPct; } else if(indexTwentySix != -1){ var enemyPctValue = 14.5; enemyPct = enemyPctValue; return enemyPct; } else if(indexTwentySeven != -1){ var enemyPctValue = 15; enemyPct = enemyPctValue; return enemyPct; } else if(indexTwentyEight != -1){ var enemyPctValue = 16.5; enemyPct = enemyPctValue; return enemyPct; } else if(indexTwentyNine != -1){ var enemyPctValue = 17.2; enemyPct = enemyPctValue; return enemyPct; } else{ alert(enemyName); } } and this is the html code Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>PSUpedia Enemy HP Calculator</title> <script type="text/javascript" src="hp_calc.js"> </script> </head> <body> <form> Enemy Level: <input type="text" id="enemyLevel"></br> Enemy Name: <input type="text" id="enemyUser"></br> <p>EnemyHp: <b id="enemyTotalHp"> </b></p></br> <input type="button" value="CLICK!" onClick="calc();"> </form> </body> </html> Hi, i have a question, is JavaScript can read an external file? i have an ear file, can it read external file without the external file compile together in the ear file? can we do so? Hi I have 2 external javascript files added in the head section of a html file but neither will work. However, if i place the javascript code in the html file it work. I'm lost and need help. Could it be the onload function
Code: <body onload="showCookies(); startBanner();"> I have some HTML that I want to put in a Javascript file and reference the HTML through external Javascript file. So I have my page, example.html Code: <html> <head></head> <body> <script type="text/javascript src="../js/external.js"> </script> </body> </html> external.js Code: document.write("<p class="txt_medium style4"> example.com<br />101 Street St.<br />City, ST, ZIP</p><p class="txt_medium style4">"The Best website." </p>"); The above code is all on one line, but is not displaying on the page. PHP is out of the question too (_._) Any thoughts? Can you place java code in an external javascript file (.js). For example can I do the following in my xx.js file. $(document).ready(function(){ <% execute some java code here %> ...execute some javascript code here... }) Can I do the above? Another question ... I know <% %> is to execute java code inside html. But what does <%-- - -%> mean? Thanks for any help. this is my first time attempting this operation. I want to take some javascript out of my html. here is the original: Code: <!--div#9begin--><div style="float: left; height: 166px; width: 1px;"> <img alt="" src="images/border_short_vert.png" height="169" width="1" /> </div><!--div#9end--> <!--div#10begin--><div style="width: 225px; height: 155px; float: left; height: 16px; background-color: #000000; color: #FFFFFF; margin-left: 0px; margin-bottom: 0px; font-size: small; padding-left: 0px;"> <img alt="" src="images/news.png" height="16" width="222" /><!--div#11begin--><div style="width: 225px; height: 155px; float: left;"></div><!--div#11end--> <script type="text/javascript">// <![CDATA[if(document.layers){document.write('<ilayer id="ns4div" width="'+swidth+'" height="'+sheight+'" bgcolor='+sbcolor+'><div id="ns4div1" width="'+swidth+'" height="'+sheight+'" onmouseover="sspeed=0;" onmouseout="sspeed=rspeed"></div></ilayer>')} if(document.getElementById||document.all){document.write('<div style="position:relative;overflow:hidden;width:'+swidth+'px;height:'+sheight+'px;clip:rect(0 '+swidth+'px '+sheight+'px 0);background-color:'+sbcolor+';" onmouseover="sspeed=0" onmouseout="sspeed=rspeed"><div id="iens6div" style="position:relative;width:'+swidth+'px;"></div></div>');} // ]]> </script> </div><!--div#10end--> and here's my attempt: Code: <div style="width: 225px; height: 155px; float: left; height: 16px; background-color: #000000; color: #FFFFFF; margin-left: 0px; margin-bottom: 0px; font-size: small; padding-left: 0px;"> <img alt="" src="images/news.png" height="16" width="222" /><script type="text/javascript" src="docwrite.js"></script> <div style="width: 225px; height: 155px; float: left;"></div> </div> along with my js: Code: if(document.layers) {document.write('<ilayer id="ns4div" width="'+swidth+'" height="'+sheight+'" bgcolor='+sbcolor+'><div id="ns4div1" width="'+swidth+'" height="'+sheight+'" onmouseover="sspeed=0;" onmouseout="sspeed=rspeed"></div></ilayer>')} if(document.getElementById||document.all) {document.write('<div style="position:relative;overflow:hidden;width:'+swidth+'px;height:'+sheight+'px;clip:rect(0 '+swidth+'px '+sheight+'px 0);background-color:'+sbcolor+';" onmouseover="sspeed=0" onmouseout="sspeed=rspeed"> <div id="iens6div" style="position:relative;width:'+swidth+'px;"></div></div>');} what is the problem? Have I not performed the extraction properly? OK, There's a script on my site that's included like <script src='somePHPfile.php?params... etc It generates an image with some text in it and a few links. When I click 'view source' it just comes up with the <script> tags and nothing else. In Firefox, if I right click on the actual image and go to this frame > view source, I can see everything it's doing. Is there some way I can access this code with Javascript/jquery? I've tried html/dom parsers, etc. with no luck. I work at a college radio station and our brand new website just went live, but we're having one particular issue... We have a set list of shows that air each day, and on the site we have a marquee tag on the homepage that scrolls through showing each show and its broadcast time. Right now we're stuck changing this schedule each day by hand, but it's tough considering we're all college students ourselves and sometimes our own schedules simply don't allow the time. Is there a code that would allow this kind of a daily update to happen automatically? The format for the schedule is such: 4 - 5 pm // "Show 01" 5 - 6 pm // "Show 02" 6 - 8 pm // "Show 03" 8 - 10 pm // "Show 04" 10 - 12 am // "Show 05" Any help would be very much appreciated! I am working on a page where the user will select a location from a dynamically generated dropdown list. I was able to create the php multidimensional array (tested and working) from a MySql database using the users information at login, but I'm having problems converting it to a javascript multidimensional array. I need to be able to access variables that I can pass to a number of text fields within an html form. For instance, if a user belongs to a company with multiple addresses, I need to be able to let them select the address they need to prepopulate specific text fields. php array creation: Code: if ($row_locations) { while ($row_locations = mysql_fetch_assoc($locations)) { $mail[$row_locations['comp_id']]=array('mailto'=>$row_locations['mailto'], 'madd'=>$row_locations['madd'], 'madd2'=>$row_locations['madd2'], 'mcity'=>$row_locations['mcity'], 'mstate'=>$row_locations['mstate'], 'mzip'=>$row_locations['mzip'], 'billto'=>$row_locations['billto'], 'badd'=>$row_locations['badd'], 'badd2'=>$row_locations['badd2'], 'bcity'=>$row_locations['bcity'], 'bstate'=>$row_locations['bstate'], 'bzip'=>$row_locations['bzip']); } } javascript function - this should create the array and send variables to text fields. Code: function updateAddress() { var mail = $.parseJSON(<?php print json_encode(json_encode($mail)); ?>); { if (comp_id in mail) { document.getElementById('mailto').value=mail.comp_id.mailto.value; document.getElementById('madd').value=mail.comp_id.madd.value; document.getElementById('madd2').value=mail.comp_id.madd2.value; document.getElementById('mcity').value=mail.comp_id.mcity.value; document.getElementById('mstate').value=mail.comp_id.mstate.value; document.getElementById('mzip').value=mail.comp_id.mzip.value; } else { document.getElementById('mailto').value=''; document.getElementById('madd').value=''; document.getElementById('madd2').value=''; document.getElementById('mcity').value=''; document.getElementById('mstate').value=''; document.getElementById('mzip').value=''; } } } Where is this breaking? Thanks in advance. Is there a Javascript code to change multiple affilate link/content daily?
Hello, I am building a web application that has quotes on it. I am planning on having all the quotes stored in a .txt file. A line space would separate the quotes. Example: "Blah Blah" "Idk what blah" "sure you do" Would this be using Javascript to pull the quotes from the txt file for use in my page be best? I need it to pull all the quotes. Reason for having it like this, I am also planning on having a random quote page where it just pulls 1 quote instead of showing all of them. I'm also open to other ideas here! David Faircloth I am attempting to create a javascript code that will write out the lyrics to the popular Christmas song, The 12 Days of Christmas. Here is what I have so far; Code: <?xml version = "1.0" encoding = "utf-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns = "http://www.w3.org/1999/xhtml"> <head> <title>ITS 200 Project 5: 12 Days of Christmas</title> <script type = "text/javascript"> <!-- document.writeln ("<h1> The 12 Days of Christmas </h1>"); for (var i =1; i = 12; i++) { var day; var addline; var gift; var pastline; switch(i) { case 1: day = "first"; addline = "A partridge in a pear tree."; pastline = "and" + addline; break; case 2: day = "second"; addline = "Two Turtle Doves"; break; case 3: day = "third"; addline = "Three French Hens"; break; case 4: day = "fourth"; addline = "Four Calling Birds"; break; case 5: day = "fifth"; addline = "FIIIIVEEE GOOOOLDEN RIIIINGS!!!!!!"; break; case 6: day = "sixth"; addline = "Six Geese-a-laying"; break; case 7: day = "seventh"; addline = "Seven Swans-a-swimming"; break; case 8: day = "eighth"; addline = "Eight Maids-a-milking"; break; case 9: day = "ninth"; addline = "Nine Ladies Dancing"; break; case 10: day = "tenth"; addline = "Ten Lords-a-leaping"; break; case 11: day = "eleventh"; addline = "Eleven Pipers Piping"; break; case 12: day = "twelfth"; addline = "Twelve Drummers Drumming"; break; } // end switch if (i==1) gift = addline; else { gift = addline + "<br>" + pastline; pastline = gift; } // end else document.writeln("<br>On the" + day + "of Christmas<br> my true love sent to me:"<br> + gift); } //--> </script> </head> <body> </body> </html> I have no idea why only the heading is coming up!? Somebody had posted this query on how to read text files using JavaScript.......can't find that post now... Anyways, though it's not possible to read text-files using JavaScript it is possible to read XML files using it. Here is an XML based JavaScript Ticker http://www.dynamicdrive.com/dynamicindex2/xmlticker.htm It works only on browsers supporting XML (IE) Enjoy! Im trying to use javascript to search a text file. text file is like this... 1111111[TAB]Project Name[TAB]Application1 2222222[TAB]Project Name[TAB]Application2 Im trying to get the javascript to let a user search for number or project name, if found it displays all the info if found. application1 or application2 (whatever is in the 3rd area) The text file can also be seperated by commas, either way is fine. can anyone help with this. ? Hello, i m new Javascript but knows basics of functions etc. ive created a website, which also has field to Submit Email addresses for newsletters.. Now, i have a TextBox (for users to write email addresses) and a Submit button in which i want to call a Javascipt script function which OnClick takes the value(email address) from the textbox and saves it to a .txt file on server. i think i am just missing a single line, the function name which will store the value.. i searched ovr the net but didnt find it.. plz help mee. Thankyou! |