JavaScript - Automatic Daily Text Update With Javascript?
I 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. Similar TutorialsI 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> 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! Hi, I can't get this to work, but I'm trying to update the text into an iframe on the same page with a button, for a game I'm making, the battle messages when you attack. Please any help greatly appreciated. here is the html file with the button and onClick Code: <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>Insert title here</title> <style type="text/css"> body { background-color: black; color: gold; } </style> </head> <body> <html> <body> <script type="text/javascript"> var my_var = "Hello World!" function text2add(){ return '<font color=gold><strong>'+my_var+'</strong></font>'; } </script> <form> <form><input type="button" value="change" onClick="text2add();"/></form> Main page! Frame below. <br><br> <iframe src="iframe.html" ></iframe> </body> </html> </body> </html> and here is the iframe page code] Code: <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>Insert title here</title> </head> <body> <script type="text/javascript"> document.write(parent.text2add()); </script> This is my iframe </body> </html> Is there a Javascript code to change multiple affilate link/content daily?
Hi, I am trying to implement something like a javascript that can click and focus the Status Update Box on Facebook. Till now, I have nothing in hand that can perform the task so I thought about a javascript that can do it. I am not even a newbie to javascript but I know that it can perform various complicated tasks on client side. Can anyone here tell me how do I click the Status Update box and set it to focused by a javascript so that when I start typing the Status box receive the text ? Thanks Hi, I am new to javascript,this is my first time using it, I am wishing to have 2 buttons on my website, one that scrolls to the bottom of my page when clicked and then stops at the bottom and one that scrolls back up the page when clicked, but I want my viewers to be able to see this movement. I have some code (below) which works fine in firefox but it doesn't work in explorer, and I can't get this code to work moving upwards (after taking away the minus from -50). Can anybody please help me I have been battling for days trying to make it work although I am finding it hard to understand javascript being a first time user. I currently have this javascript : [CODE] <head> <script language="JavaScript"> function pageScrollup() { window.scrollBy(0,-50); // horizontal and vertical scroll increments if (window.pageYOffset) { scrolldelay = setTimeout('pageScrollup()',5); } } </script> </head> <body> <a href="JavaScriptageScrollup()">Back to Top</a> </body>[ICODE] Any help is greatly appreciated. OrangeAnt Hello im trying to update a text area value with edited code with javascript, i dont know how to and im asking if you guys know
Hi all, I'm a JavaScript newbie and I am trying to create a situation where a user clicks a button, a popup is launched in which they have a textarea to enter some text. Once they hit submit, the popup should disapear and a certain text element on the previous page should be updated to show what they entered. Its like this, but obviously it wouldn't be on the same page: http://www.tizag.com/javascriptT/jav...-innerHTML.php - updating text based on user input. I have the popup part working just fine: index.php Code: <script type="text/javascript"> <!-- function editText() { sList = window.open("editText.html", "list", "width=300,height=300"); } // --> </script> which is triggered by an onclick="editText()" however I can seem to figure out how to update the box with the text they enter in the popup part. I'm sure it is something do with innnerHTML. editText.html Code: <script type="text/javascript"> function changeText2(){ var userInput = document.getElementById('userInput').value; document.getElementById('boldStuff2').innerHTML = userInput; } </script> <p>Welcome to the site <b id='boldStuff2'>dude</b> </p> <input type='text' id='userInput' value='Enter Text Here' /> <input type='button' onclick='changeText2()' value='Change Text'/> Can anybody help me out here? Many thanks As of right now I have a code that will work in IE but wont work in FireFox...go figure. Basically what I want to have happen is when you type in an area code it will provide an output in a predetermined area of the page. For Example: Input- 512 Output - Austin, TX The code that I have doesn't work with firefox and I was just wondering if there was a code that would allow that to happen. Thanks! Hello All, I'm working on a project which requires a small portion from a large table of information to be displayed on a webpage (sort of like a magnifying glass). The display will be a table of fixed size (m by n cells). Some of the cells will be merged. When the table updates, different sets of cells may be merged. It needs to be coded in HTML5, which I assume includes the use of JavaScript and CSS (The specs of this is rather unclear at the moment, so I'm going to cover all bases). Anyhow, looking through the HTML5 and JavaScript tutorials, I found two ways to solve this problem. One way would be to have a script to parse out the relevant information, and have it output into a table (dynamically generating the HTML required). The second way would be to have the script draw the table on its own in a canvas. User events (such as arrow keys on the keyboard) will change the position of the focus (move the magnifying glass in a cardinal direction). I hit a small snag with the first solution - Is it possible to update the table on the page (including changing the structure of it) without having to refresh? If you could point me to a relevant tutorial or example on the web, I'd greatly appreciate it. Using the following script: <script language="JavaScript">TargetDate = "01/22/2010 7:50 AM UTC-0500"; BackColor = "palegreen"; ForeColor = "navy"; CountActive = true; CountStepper = -1; LeadingZero = true; DisplayFormat = "%%D%% Days, %%H%% Hours, %%M%% Minutes, %%S%% Seconds."; FinishMessage = "Call In Now!!! Lines Are Open" </script> Want target date to equal every day so it resets after the target date and time is hit. Optionally, it would be nice to have it reset 60 minutes after target is hit (so the FinishMessage can display) but if that's too complicated, I'd be happy to not have to manually reset the date every day. I apologize in advance for being a newbie and this may be a straight-forward and simple issue. Greetings. I am trying to create an "image of the day" for a site where the image will change automatically every 24 hours. Currently, I have 30 images in a folder named "petday" (no quotes) and I tried the following code (found in this forum) but I cannot get it to work. Any help or suggestions would be greatly appreciated. On a side note, I am very new to JavaScript and I know there is an easier way to write this but I am not real clear on how to do it. I have been reading the lessons found at W3 schools and I think I can use a switch statement? Is that correct? Code: <SCRIPT Language="JavaScript"> var now = new Date(); var dd = now.getDate(); if (dd==1) document.write('<img src="petday/image1.jpg">'); else if (dd==2) document.write('<img src="petday/image2.jpg">'); else if (dd==3) document.write('<img src="petday/image3.jpg">'); else if (dd==4) document.write('<img src="petday/image4.jpg">'); else if (dd==5) document.write('<img src="petday/image5.jpg">'); else if (dd==6) document.write('<img src="petday/image6.jpg">'); else if (dd==7) document.write('<img src="petday/image7.jpg">'); else if (dd==8) document.write('<img src="petday/image8.jpg">'); else if (dd==9) document.write('<img src="petday/image9.jpg">'); else if (dd==10) document.write('<img src="petday/image10.jpg">'); else if (dd==11) document.write('<img src="petday/image11.jpg">'); else if (dd==12) document.write('<img src="petday/image12.jpg">'); else if (dd==13) document.write('<img src="petday/image13.jpg">'); else if (dd==14) document.write('<img src="petday/image14.jpg">'); else if (dd==15) document.write('<img src="petday/image15.jpg">'); else if (dd==16) document.write('<img src="petday/image16.jpg">'); else if (dd==17) document.write('<img src="petday/image17.jpg">'); else if (dd==18) document.write('<img src="petday/image18.jpg">'); else if (dd==19) document.write('<img src="petday/image19.jpg">'); else if (dd==20) document.write('<img src="petday/image20.jpg">'); else if (dd==21) document.write('<img src="petday/image21.jpg">'); else if (dd==22) document.write('<img src="petday/image22.jpg">'); else if (dd==23) document.write('<img src="petday/image23.jpg">'); else if (dd==24) document.write('<img src="petday/image24.jpg">'); else if (dd==25) document.write('<img src="petday/image25.jpg">'); else if (dd==26) document.write('<img src="petday/image26.jpg">'); else if (dd==27) document.write('<img src="petday/image27.jpg">'); else if (dd==28) document.write('<img src="petday/image28.jpg">'); else if (dd==29) document.write('<img src="petday/image29.jpg">'); else if (dd==30) document.write('<img src="petday/image30.jpg">'); </SCRIPT> I am completely a beginner at coding and really do not know much right now. This is the day of week link rotation script which works just great: Code: <script type="text/javascript"> <!-- var MyEveryDayLinks = [ ['Sunday', 'http://www.google.com', 'Google'], ['Monday', 'myURL', 'LinkName'], ['Tuesday', 'myURL', 'LinkName'], ['Wednesday', 'myURL', 'LinkName'], ['Thursday', 'myURL', 'LinkName'], ['Friday', 'myURL', 'LinkName'], ['Saturday', 'myURL', 'LinkName'] ]; var today = new Date(); var L = today.getDay(); document.write('Today is ' + MyEveryDayLinks[L][0] + '. My daily URLs: <a href="' + MyEveryDayLinks[L][1] + '">' + MyEveryDayLinks[L][2] + '<\/a>.') ; // --> </script> Unfortunately I can't open urls in a new window. I would so like this to work...but don't know why i can't make it work. I've tried something like this with no luck...any ideas?: Code: <a href="javascript:[window.open(' + MyEveryDayLinks[L][1] + ', 'height=200, width=200',)];">' + MyEveryDayLinks[L][2] + '<\/a>.') ; I have one image on a page and I am trying to mix 2 javascripts actions on that image: - the first one is an automatic daily change of images (3 different images in this example) - the second one is the display of the same image in bigger when the mouse is over it. The total of images are 6 (2 different sizes for 3 images). I have made a search but I didn't find the solution. Here is the code (the daily change works but not the rollover. Thank you to correct it or giving an other solution. (My level in Javascript: low) [CODE]<SCRIPT LANGUAGE="JavaScript"> function todaysPhoto(){ var i= 3 ; var todaysFoto=new Array(); todaysFoto[1]="img1_small.jpg"; todaysFoto[2]="img2_small.jpg"; todaysFoto[3]="img3_small.jpg"; var todaysPic=new Array(); todaysPic[1]="img1_big.jpg"; todaysPic[2]="img2_big.jpg"; todaysPic[3]="img3_big.jpg"; t=new Date().getTime(); var days=Math.floor(t / 86400000) % i+1; document.getElementById("todaysfoto").src="images/photos/"+todaysFoto[days]; function SwapImg(){ document.todaysfoto.src ="images/photos/"+todaysPic[days]; return true;} function SwapBack(){ document.todaysfoto.src ="images/photos/"+todaysFoto[days]; return true;} </SCRIPT> <body onload="todaysPhoto()"> <a href="" onmouseover="SwapImg()" onmouseout="SwapBack()"> <img name="todaysfoto" width="150px" height="100px" id ="todaysfoto" /></a>[CODE] I'm creating a page that calculates a number depending on what value is inputted into a text field. I need to create some javascript that updates this new calculated value and outputs it next to the input field. Anytime the user changes the number, it recalculates the value. My calculation is currently being produced by PHP, however if I need to, I can create javascript as well to recalculate these numbers. My formulas for all 4 calculations are as follows: First: Inputted Value * 10 Second: Inputted Value * 20 Third: Inputted Value / 2 Fourth: Inputted Value * 2 Here is my code I'm working with: PHP Code: <?php session_start(); $username = $_SESSION['username']; include_once('inc/connect.php'); $credquery = mysql_query("SELECT * FROM userstats WHERE username='$username'"); $row = mysql_fetch_assoc($credquery); $credits = $row['credits']; $bannercredits = $row['bannercredits']; $textcredits = $row['textcredits']; $sitetobanner = $_POST['sitetobanner']; $sitetotext = $_POST['sitetotext']; $bannertotext = $_POST['bannertotext']; $texttobanner = $_POST['texttobanner']; if (isset($sitetobanner)){ $bannerimp = round($_POST['bannerimp']); if ($bannerimp > 1){ $s = "s"; } if ($bannerimp <= $credits){ $newcredits = $credits - $bannerimp; $newbannercredits = $bannerimp * 10; $totalbannercredits = $bannercredits + $newbannercredits; $updatebanner = mysql_query("UPDATE userstats SET credits='$newcredits', bannercredits='$totalbannercredits' WHERE username='$username'"); $credits = $row['credits']; $bannercredits = $row['bannercredits']; $textcredits = $row['textcredits']; $convertedbanner = "You converted ".$bannerimp." credit".$s." into ".$newbannercredits." banner impressions"; } else{ if ($credits>1){ $mycredits = $credits - 1;} $errorbanner = number_format($mycredits, 0, '.', ''); } } if (isset($sitetotext)){ $textimp = round($_POST['textimp']); if ($textimp > 1){ $s = "s"; } if ($textimp <= $credits){ $newcredits = $credits - $textimp; $newtextcredits = $textimp * 20; $totaltextcredits = $textcredits + $newtextcredits; $updatebanner = mysql_query("UPDATE userstats SET credits='$newcredits', textcredits='$totaltextcredits' WHERE username='$username'"); $credits = $row['credits']; $bannercredits = $row['bannercredits']; $textcredits = $row['textcredits']; $convertedtext = "You converted ".$textimp." credit".$s." into ".$newtextcredits." text ad impressions"; } else{ if ($credits>1){ $mycredits = $credits - 1;} $errortext = number_format($mycredits, 0, '.', ''); } } if (isset($texttobanner)){ $texttobannerimp = round($_POST['texttobannerimp']); if ($texttobannerimp > 1){ $s = "s"; } if ($texttobannerimp <= $textcredits){ if ($texttobannerimp>=2&&$texttobannerimp>""){ $newcredits = $textcredits - $texttobannerimp; $newbannercredits = $texttobannerimp / 2; $totalbannercredits = $bannercredits + $newbannercredits; $updatebanner = mysql_query("UPDATE userstats SET textcredits='$newcredits', bannercredits='$totalbannercredits' WHERE username='$username'"); $credits = $row['credits']; $bannercredits = $row['bannercredits']; $textcredits = $row['textcredits']; $convertedtextimp = "You converted ".$texttobannerimp." text ad impression".$s." into ".$newbannercredits." banner impressions"; } else{ $convertedtextimp = "You Hag"; } } else{ if ($textcredits>1){ $mycredits = $textcredits - 1;} $errortextimp = number_format($mycredits, 0, '.', ''); } } if (isset($bannertotext)){ $bannertotextimp = round($_POST['bannertotextimp']); if ($bannertotextimp > 1){ $s = "s"; } if ($bannertotextimp <= $bannercredits){ $newcredits = $bannercredits - $bannertotextimp; $newtextcredits = $bannertotextimp * 2; $totaltextcredits = $textcredits + $newtextcredits; $updatebanner = mysql_query("UPDATE userstats SET bannercredits='$newcredits', textcredits='$totaltextcredits' WHERE username='$username'"); $credits = $row['credits']; $bannercredits = $row['bannercredits']; $textcredits = $row['textcredits']; $convertedbannerimp = "You converted ".$bannertotextimp." banner impression".$s." into ".$newtextcredits." text impressions"; } else{ if ($bannercredits>1){ $mycredits = $bannercredits - 1;} $errorbannerimp = number_format($mycredits, 0, '.', ''); } } ?> <html> <head> <title>Convert Credits</title> <script type="text/javascript" language="javascript"> function inputLimiter(e,allow) { var AllowableCharacters = ''; if (allow == 'NumbersOnly'){AllowableCharacters='0123456789.';} var k; k=document.all?parseInt(e.keyCode): parseInt(e.which); if (k!=13 && k!=8 && k!=0){ if ((e.ctrlKey==false) && (e.altKey==false)) { return (AllowableCharacters.indexOf(String.fromCharCode(k))!=-1); } else { return true; } } else { return true; } } </script> </head> <body> <h1>Convert Credits</h1><br /> Credits: <?php echo $credits; ?><br /> Banner Impressions: <?php echo $bannercredits; ?><br /> Text Ad Impressions: <?php echo $textcredits; ?><br /> <form action="convert.php" method="POST"> <h3>Credits To Banner Impressions</h3> Convert <input type="text" name="bannerimp" id="NumbersOnly" onkeypress="return inputLimiter(event,'NumbersOnly')" value="<?php echo $errorbanner; ?>" onChange=""> credits into BLANK Banner Impressions! <input type="submit" name="sitetobanner" value="Convert"><br /> <?php echo $convertedbanner; ?> </form> <form action="convert.php" method="POST"> <h3>Credits To Text Ad Impressions</h3> Convert <input type="text" name="textimp" id="NumbersOnly" onkeypress="return inputLimiter(event,'NumbersOnly')" value="<?php echo $errortext; ?>"> credits into BLANK Text Ad Impressions! <input type="submit" name="sitetotext" value="Convert"><br /> <?php echo $convertedtext; ?> </form> <form action="convert.php" method="POST"> <h3>Text Ad To Banner Impressions</h3> Convert <input type="text" name="texttobannerimp" id="NumbersOnly" onkeypress="return inputLimiter(event,'NumbersOnly')" value="<?php echo $errortextimp; ?>"> Text Ad Impressions into BLANK Banner Impressions! <input type="submit" name="texttobanner" value="Convert"><br /> <?php echo $convertedtextimp; ?> </form> <form action="convert.php" method="POST"> <h3>Banner To Text Ad Impressions</h3> Convert <input type="text" name="bannertotextimp" id="NumbersOnly" onkeypress="return inputLimiter(event,'NumbersOnly')" value="<?php echo $errorbannerimp; ?>"> Banner Impressions into BLANK Text Ad Impressions! <input type="submit" name="bannertotext" value="Convert"><br /> <?php echo $convertedbannerimp; ?> </form> </body> </html> Hi I am trying to get javascript to update a database for me. The reason is I need to use JS and not ASP is because I need to update whenever a user clicks on a button and from what I am told ASP can not do this. I tried following an example, and this is what I came up with. However I get the errors Error: Object expected and Excptected Hexadecimal Digit. Here is the code Code: <script language=javascript> function update() { var adoConn = new ActiveXObject("ADODB.Connection"); var adoRS = new ActiveXObject("ADODB.Recordset"); adoConn.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source='\\data\user.mdb'"); adoRS.Open("Select * From ptotbl Where ID = 454"); adoRS.Edit; adoRS.Fields("Delete").value = "True"; adoRS.Update; adoRS.Close(); adoConn.Close(); } Thanks I'm using a image of the day script and my pictures will not be located at the site where the code will be. Code: images[0] = "<img src='yourimage.jpg'>" Do I/can I use the link such as <a href="http://www.sample.com/mphases.htm"> right where (yourimage) is, in between the quotes to link to an offsite picture? Could someone retype this snippet of code showing how it would look for me? Thanks I'm attempting to modify a facebook app I purchased that allows friends to send gifts to each other. The problem with the program is that when gifts are accepted, they continue to show on the "accept gift" page. I'd like to change it so that after gifts are accepted, they no longer show on that page, preventing the user from wondering "which gifts have I already accepted?" Later, I'd like to also create a reject gift option, but 1st things 1st. The program is written in php, html, and javascript. I decided one solution was to add a new empty column to the sql table called "accepted". When the user presses "accept gift" I'm thinking an onclick event could be used to add a "y" (for yes) to that record in the database. Then modify the code that displays the gifts to only show gifts from the table 'WHERE' accepted is equal to null. My questions a Is this a logical approach? If so, is the process: create a javascript function that updates mysql and call that function with an onclick event? What about sql injection vulnerabilities? I've read a lot about ajax and HTTP request being the way to do things like this, but could not find an example that represented what I want to do. After weeks of reading, I'm still lost. |