JavaScript - How To Display A Different Array Element Each Day Of The Year
I want to create an array for a religious website that will display a different Bible verse for each day of the year.
This is how I incremented each day of the year. Code: var myDate=new Date(); myDate.setFullYear(2011,2,4); myDate.setDate(myDate.getDate()+1); How do I make the connection between the array and the new date as it changes? This is a snippet from the array. Code: var dailyVerseRef=new Array(); dailyVerseRef[0]="Genesis 1:1"; dailyVerseRef[2]="Genesis 1:2"; dailyVerseRef[3]="Genesis 1:3"; dailyVerseRef[4]="Genesis 1:4"; dailyVerseRef[5]="Genesis 1:5"; dailyVerseRef[6]="Genesis 1:6"; dailyVerseRef[7]="Genesis 1:7"; dailyVerseRef[8]="Genesis 1:8"; I used a switch to go through the days of the week, but to go through the days of the year seems more difficult. Similar TutorialsHere is my code... Code: <html> <head> <script type="text/javascript"> function nameofmonth(month) { var monthname=new Array("January","February","March","April","May","June","July","August","September","October","November","December") return monthname[month] } function monthdays(month,year) { var daysofmonth=new Array(31,28,31,31,30,31,31,31,30,31,30,31) if(year%4==0) daysofmonth[1]=29 return daysofmonth[month] } function close(){ document.getElementById("container").style.display='none' } function table() { var now=new Date() var hour=now.getHours() var minute=now.getMinutes() var second=now.getSeconds() var date=now.getDate() var month=now.getMonth() var year=now.getFullYear() now.setFullYear(year,month,1) var firstday=now.getDay() var monthname=nameofmonth(month) var daysofmonth=monthdays(month,year) if(firstday>0) var k=-(firstday-1) else k=1 var table="<table border=5 cellspacing=3cellpadding=8>" table +="<tr><th colspan=7>"+monthname + date+"th</th> <td style='cursor:pointer' onclick='close()'>[close]</td></tr>" table +="<tr><th>sun</th><th>mon</th><th>tue</><th>wed</th><th>thu</th><th>fri</><th>sat</th></tr>" for(var i=0;i<5;i++) { table+="<tr>" for(var j=0;j<7;j++) { if(k<=daysofmonth && k>0) { if(k==date) table+='<td id="clock" bgcolor="aqua">'+k+'</td>' else table+='<td style="cursor:pointer">'+k+'</td>' k=parseInt(k) } else table+="<td></td>" k++ } table+="</tr>" document.getElementById("calender").innerHTML=table } } </script> </head> <body> <input type="text" onclick="table()"/> <table id="container"><tr><td id="calender"></td></tr></table> </body> </html> HERE is a close cell in table.when it is clicked,the close() function will called and the calender will disappear.but it is not happening.please help me ,what is wrong.Thanks in advance... Im trying to add to each element within an array. In this program I have an existing array which is called aScores. I have copied its contents into another array called aScores using slice. Now Im trying to add the value of variable called classCurve to each element of aCurve using a for loop (see under the Curve Scores functrion section). However, it does not seem to add the two together(e.g 78 + 5). Any advice would be very helpful. Here is my code: Code: <?xml version="1.0" encoding="UTF-8"?> <!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> <title></title> <script> <!-- var aScores = new Array(); //array to hold test scores var aCurve = new Array(); //array to hold test scores with curve var classAveRounded = 0; //average of test scores var howLong = 0; //length of array -- contingent on how many test scores entered //------------------- LoadScores function ----------------------------- function LoadScores() { var classAve = 0; var rawScores = document.getElementById("Scores").value; aScores=rawScores.split(","); //seperate the test scores by comma //alert(aScores[1]); //test to see if they are separated var howLong = aScores.length; //variable to measure how long the array is for(i=0; i<howLong; i++){ aScores[i] = parseInt(aScores[i]); //convert strings to numbers } //alert(aScores[0] + aScores[1]); //test to make sure array contains numbers aScores.sort(sortNumber); //sort the scores from highest to lowest //insert scores from the array into the score text boxes. for (i=0; i<howLong; i++) { document.getElementById("Score" + i).value = aScores[i]; } //total the test scores var total=0; for(i=0; i<howLong; i++) { total += aScores[i]; } //average the total and insert it into the Average textbox(Math.ceil rounds up aveCalc). classAve = total/howLong; classAveRounded = Math.ceil(classAve); document.getElementById("Average").value = classAveRounded; } //------------------- sortNumber function ------------------------------ function sortNumber(a,b){ return b-a; } //------------------- CurveScores function ----------------------------- function CurveScores() { var classCurve = 0; alert(classAveRounded); if(classAveRounded<75) { classCurve=(75-classAveRounded); }else{ classCurve=0; } alert(classCurve); aCurve=aScores.slice(); //alert(aCurve[7]); //test to see if aCurve holds test scores for(i=0; i<howLong; i++) { aCurve[i]=aCurve[i] + classCurve; } // alert(aCurve[0]); //total the curved scores var totalCurvedScores=0; for(i=0; i<howLong; i++) { totalCurvedScores += aCurve[i]; } //average the total and insert it into the CurvedAverage textbox(Math.ceil rounds up aveCalc). curvedAve = totalCurvedScores/howLong; curvedAveRounded = Math.ceil(curvedAve); document.getElementById("CurvedAverage").value = curvedAveRounded; } --> </script> </head> <body> <table border="1"> <tr style="background-color:#F0F0F0; font-size:10pt; font-weight:bold; text-align:center; vertical-align:bottom"> <td>Score</td> <td>Curved</td> <td>Grade</td> </tr> <tr> <td> <input id="Score0" type="text" style="width:60px;text-align:right"/><br/> <input id="Score1" type="text" style="width:60px;text-align:right"/><br/> <input id="Score2" type="text" style="width:60px;text-align:right"/><br/> <input id="Score3" type="text" style="width:60px;text-align:right"/><br/> <input id="Score4" type="text" style="width:60px;text-align:right"/><br/> <input id="Score5" type="text" style="width:60px;text-align:right"/><br/> <input id="Score6" type="text" style="width:60px;text-align:right"/><br/> <input id="Score7" type="text" style="width:60px;text-align:right"/><br/> <input id="Score8" type="text" style="width:60px;text-align:right"/><br/> <input id="Score9" type="text" style="width:60px;text-align:right"/><br/> </td> <td> <input id="CurvedScore0" type="text" style="width:60px;text-align:right"/><br/> <input id="CurvedScore1" type="text" style="width:60px;text-align:right"/><br/> <input id="CurvedScore2" type="text" style="width:60px;text-align:right"/><br/> <input id="CurvedScore3" type="text" style="width:60px;text-align:right"/><br/> <input id="CurvedScore4" type="text" style="width:60px;text-align:right"/><br/> <input id="CurvedScore5" type="text" style="width:60px;text-align:right"/><br/> <input id="CurvedScore6" type="text" style="width:60px;text-align:right"/><br/> <input id="CurvedScore7" type="text" style="width:60px;text-align:right"/><br/> <input id="CurvedScore8" type="text" style="width:60px;text-align:right"/><br/> <input id="CurvedScore9" type="text" style="width:60px;text-align:right"/><br/> </td> <td> <input id="Grade0" type="text" style="width:60px;text-align:center"/><br/> <input id="Grade1" type="text" style="width:60px;text-align:center"/><br/> <input id="Grade2" type="text" style="width:60px;text-align:center"/><br/> <input id="Grade3" type="text" style="width:60px;text-align:center"/><br/> <input id="Grade4" type="text" style="width:60px;text-align:center"/><br/> <input id="Grade5" type="text" style="width:60px;text-align:center"/><br/> <input id="Grade6" type="text" style="width:60px;text-align:center"/><br/> <input id="Grade7" type="text" style="width:60px;text-align:center"/><br/> <input id="Grade8" type="text" style="width:60px;text-align:center"/><br/> <input id="Grade9" type="text" style="width:60px;text-align:center"/><br/> </td> </tr> <tr> <td><input id="Average" type="text" style="width:60px;text-align:right"/></td> <td><input id="CurvedAverage" type="text" style="width:60px;text-align:right"/></td> <td> </td> </tr> <tr> <td><input type="button" value="Load" style="width:60px;font-size:7pt" onclick="LoadScores()"/></td> <td><input type="button" value="Curve" style="width:60px;font-size:7pt" onclick="CurveScores()"/></td> <td><input type="button" value="Grades" style="width:60px;font-size:7pt" onclick="AssignGrades()"/></td> </tr> </table> <div style="position:relative; left:225px; top:-25px; font-size:10pt"> <b>Enter Scores: </b> <input id="Scores" type="text" style="width:250px; font-family:courier new" value="40,46,48,56,62,64,66,70,76,78"/> </div> </body> </html> Hi. I'm fairly new to javascript. I have a code where I'm trying to generate scrollx1 through scrollx100. I can get the array to work with doc.write and I can get one concat variable to work in the element but when I combine them it doesn't work. Any suggestions as to what I need to add to this code: Code: var sp=1; for (sp=1;sp<=100;sp++) { var sx = "scrollx"; var sy = "scrolly"; var thissx = sx + sp; var thissy = sy + sp; theForm[thissx].value = scrollx; theForm[thissy].value = scrolly; } Any help would be much appreciated!! What I need help with is sorting the [0] of my array. I need it to sort so that if the user puts in his last name, whether its uppercase or lowercase (Adams, adams), it will sort through the list of students I add, and put them in an alphabetic order i.e adams, Adams, cook, Douglas....and so on. Here is the code that I have below for just sorting by last name, which will seperate the lowercase entries from the uppercase entries. That would be the opposite of what I want. I had it sorted so that it would sort the [o], which is where the last name value is located. Any thoughtful help would be appreciated. Code: function Last_names( s1, s2 ) { if ( s1[0] > s2[0] ) return 1; return 0; } function sortLast(form) { StudentsLists.sort( Last_names ); windows(form);//calling the windows function each time the sortLast function is called } --------RESOLVED-------- I am trying to make a finance tracker, but for some reason this code will only output the first transaction: Code: <html> <head> <style> tr:nth-child(even) {background: #CCC} tr:nth-child(odd) {background: #FFF} </style> <script type="text/javascript"> var finance={ ls : localStorage, codes : new Array(), getCodes : function (){ finance.codes=(eval("["+finance.ls.code+"]")) return finance.codes; }, dates : new Array(), getDates : function (){ finance.dates=(eval("["+finance.ls.dates+"]")) return finance.dates; }, desc : new Array(), getDescs : function (){ finance.desc=(eval("["+finance.ls.desc+"]")) return finance.desc; }, change : new Array(), getChanges : function (){ finance.change=(eval("["+finance.ls.change+"]")) return finance.change; }, getAll : function(){ var t=new Array(); t[0]=finance.getCodes(); t[1]=finance.getDates(); t[2]=finance.getDescs(); t[3]=finance.getChanges(); return t; }, getRows : function(){ var temp=new Array(); var bal=0; for (i=0;i<finance.getAll()[0].length;i++){ bal+=finance.getAll()[3][i]; var temp3=document.createElement("tr"); var temp4=new Array(); for(a=0;a<6;a++){ temp4[a]=(document.createElement("td")) } temp4[0].innerHTML=finance.getAll()[0][i]; temp4[1].innerHTML=finance.getAll()[1][i]; temp4[2].innerHTML=finance.getAll()[2][i]; temp4[3].innerHTML=((finance.getAll()[3][i]>0)?"":finance.getAll()[3][i]); temp4[4].innerHTML=((finance.getAll()[3][i]<0)?"":finance.getAll()[3][i]); temp4[5].innerHTML=bal; for(i=0;i<6;i++){ temp3.appendChild(temp4[i]); } temp.push(temp3); } for(i=0;i<temp.length;i++){ document.getElementById("fin").appendChild(temp[i]); } } } localStorage.code='" ","1001","DC"'; localStorage.dates='" ","8/30/2010","9/4/2010"'; localStorage.desc='"Starting","Check for Bob","ATM"'; localStorage.change='100,-10,-20'; </script> </head> <body onload="finance.getRows();"> <table id="fin"> <tr><th>Code</th><th>Date</th><th>Description</th><th>Payment</th><th>Deposit</th><th>Balance</th></tr> </table> </body> </html> hahahahaha wow im dumb i forgot that nesting two for statements that use "i" is a nono also i know the code may be sloppy, i am just building it now, i will clean it up later. Hi. I'm fairly new to javascript. I have a code where I'm trying to generate scrollx1 through scrollx100. I can get the array to work with doc.write and I can get one concat variable to work in the element but when I combine them it doesn't work. Any suggestions as to what I need to add to this code: var sp=1; for (sp=1;sp<=100;sp++) { var sx = "scrollx"; var sy = "scrolly"; var thissx = sx + sp; var thissy = sy + sp; theForm[thissx].value = scrollx; theForm[thissy].value = scrolly; } Any help would be much appreciated!! Hi all. I am having a problem understanding exactly how setInterval and setTimeout work and really need some help. I want to create an array and then print out each element one at a time at one second intervals. I've only been able to come up with something like this, but it just prints the last value of the array after a second. Code: <script type = "text/javascript"> <!-- var myArray = new Array(); for (var i = 0; i < 11; i++){ myArray[i]=i+50; } for (var i = 0; i < myArray.length-1; i++){ setInterval("document.getElementById('here').innerHTML = myArray[i];", 1000); } //--> </script> <div id="here">Stuff here</div> Hi, Below is the code which is used to validate the entries on a form(some field are not be left blank). The user gets the msg when he hits the "Check"button. The problem is after the user gets the msg, I am not able to set the focus in the field which is the first element of an error array which stores the info about the fields with errors on this form. Please help. ========================================================== <html> <head> <script type="text/javascript"> function check_alert() { var errors=[]; if (text1.value==""||text1.value==null) { errors[errors.length]="Please enter the Company Name"; } if(text3.value==""||text3.value==null) { errors[errors.length]="Please enter the Address"; } if(text5.value==""||text5.value==null) { errors[errors.length]="Please enter the City"; } if(text6.value==""||text6.value==null) { errors[errors.length]="Please enter the Zip/Costal Code"; } if(text7.value==""||text7.value==null) { errors[errors.length]="Please enter the Country"; } if (errors.length>0) { reportErrors(errors); return false; } else return true; } function reportErrors(errors) { var msg="There are some errors..\n"; var numerror; for (var i=0;i<errors.length;i++) { numerror=i+1; msg+="\n"+numerror+"."+errors[i]; } alert(msg); document.form.element(errors[0]).focus(); } </script> </head> <body onload="text1.focus()"> Company:<input type="text" name="text1" /><br> Division:<input type="text" name="text2" /><br> Address1:<input type="text" name="text3" /><br> Address2:<input type="text" name="text4" /><br> City:<input type="text" name="text5" /><br> State:<select name="state"> <option value= "Alabama" selected>Alabama</option> <option value= "Alaska">Alaska</option> <option value= "Arizona">Arizona</option> <option value= "Arkansas">Arkansas</option> </select><br> Zip/Postal Code:<input type="text" name="text6"/><br> Country:<input type="text" name="text7" /><br> <input type="button" value="Check" onclick="return check_alert()"/> </body> </html> ======================================================= I'm hoping someone can help correct a small problem with this script, which is intended to highlight particular text strings. Background: The script is being used at a MediaWiki site, and is adapted from a working script from Wikipedia (highlightmyname.js). The original script highlights the logged-in user's username (represented by wgUserName). I've made a copy of the script, which you can see in full here, and adapted it to work on a pre-defined array of names, adding: Code: var Admin; var ArrayAdmins = ['Adam', 'Axiomist', 'Matt', 'Steve']; for (Admin in ArrayAdmins) I also replaced each instance of wgUserName with ArrayAdmins[Admin] The problem: is that, instead of highlighting all instances of every element in ArrayAdmins, only the last element listed ('Steve') is being used. So my question is, what change(s) need to be made to apply function highlightmyname to every element in ArrayAdmins? Any help would be hugely appreciated! Hey guys, I'm hoping this is possible or that there is an easier way to do this. I'm having an issue with displaying data from one array that contains information about users in a table that is controlled by a different array. Is it possible to do this or is this use of arrays to display the data the wrong approach? The table is located on one webpage, I simply want to extract one piece of information that I have placed in the initial array as part of the login script that contains user information (for validation for login etc) and display it in a table on the new webpage that is opened as a result of successful validation of the user details. I'm completely stumped and after many attempts I just can't seem to get it to work. I would like to display the elements in my array but it is NOT working. Here's my code: Code: <HTML> <HEAD> <TITLE>Test Input</TITLE> <script type="text/javascript"> function addtext() { var openURL=new Array("http://google.com","http://yahoo.com","http://www.msn.com","http://www.bing.com"); document.writeln('<table>'); for (i=0;i<=openURL.length-1;i++){ document.writeln('<tr><td>openURL[i]</td></tr>'); } document.writeln('</table>'); } </script> </HEAD> <body onload="addtext()"> </BODY> </HTML> Here's the ouput: Code: openURL[i] openURL[i] openURL[i] openURL[i] It should display: Code: http://google.com http://yahoo.com http://msn.com http://bing.com Any comments or suggestions are greatly apprecitated. thanks The bit of code in bold in the code below is giving me this error in IE: Error: Code: Webpage error details User Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; Trident/4.0; Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) ; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.5.30729; Tablet PC 2.0; InfoPath.2; OfficeLiveConnector.1.4; .NET CLR 3.0.30729; OfficeLivePatch.1.3; MSN OptimizedIE8;ENGB) Timestamp: Tue, 16 Mar 2010 15:07:11 UTC Message: HTML Parsing Error: Unable to modify the parent container element before the child element is closed (KB927917) Line: 0 Char: 0 Code: 0 URI: http://www.mateinastate.co.uk/users/mateinastate Code: Code: if(document.getElementById('msn1').innerHTML=="") { document.getElementById('msn1').style.display='none'; } if(document.getElementById('yahoo1').innerHTML=="") { document.getElementById('yahoo1').style.display='none'; } if(document.getElementById('skype1').innerHTML=="") { document.getElementById('skype1').style.display='none'; } if(document.getElementById('facebook1').innerHTML.toLowerCase().substr(0,18)=='<a href="http://">') { document.getElementById('facebook1').style.display='none'; } else if(document.getElementById('facebook1').innerHTML.toLowerCase().substr(0,11)=='<a href="">') { document.getElementById('facebook1').style.display='none'; } else { document.getElementById('fbook-add').innerHTML='Facebook Profile'; } What it's saying isn't actually true (I don't think)... this is how the section is laid out: Code: <div id="submenu1" class="anylinkcss"> <ul> <li class="contact-pm"><a href="/index.php?do=pm&act=new&to=$RateViewProfileUserName$&returnurl=$ReturnURL$">PM me</a></li> <li class="contact-email"><a href="/index.php?do=email&id=$RateViewProfileUserId$">E-mail me</a></li> <li class="contact-msn" id="msn1">$RateViewProfileUser-profile_msn$</li> <li class="contact-yahoo" id="yahoo1">$RateViewProfileUser-profile_yahoo$</li> <li class="contact-skype" id="skype1">$RateViewProfileUser-profile_skype$</li> <li class="contact-facebook" id="facebook1"><a href="$RateViewProfileUser-profile_facebook$"><span id="fbook-add"></span></a></li> </ul> </div> <script type="text/javascript" src="/html_1/js/contact-information.js"></script> Does anyone know why this might error in just IE? Hi all. I'm trying stuff out for learning. What I would like to do is display the first error message in array ie 'required' if its still wrong when validate again I want message two to display ie 'still required' but I can't work it out. As expected, I always get the last message. Can it be done as I would like or is it done another way? Code: var errmail = []; errmail[0]="Required"; errmail[1]="Still required"; errmail[2]="Oi idiot, enter a VALID email"; /other code here/ email checked and failed for (i=0; i<errmail.length; i++) document.getElementById("emerr").innerHTML = errmail[i] ; /other code/ any positive input very welcome LT ps:-)smile trying to display an image using an img tag which uses the array value as the image path here is where i set up the array called " img_path " in the head <script type="text/javascript"> var img_path = [ 'images/west/Home.png', 'images/west/Cold.png', 'images/west/Ocean.png', 'images/west/Beach.png' ]; </script> later, in the body, i'm trying to use the array value to splash the image on the web page, like this <img src=" img_path[0] " width="250" height="250"> the result splashes a 250x250 image area on the webpage but not the image (?). why not the image ? i tested the value of "img_path[0]" and it prints out correctly as 'images/west/Home.png' i even cut/pasted this code in and the image splashed out just fine. <img src=" images/west/Home.png " width="250" height="250"> not sure why this won't work? anyone have any suggestions? thanks, Paul weather in Kalispell, MT this morning........not to bad, about 28deg. Merry Christmas and Happy New Year to all. I have this simple php array. The array will dynamically pull results from the db in the future. PHP Code: <?php $dataArray = array ( 'id1' => array ( 'icon' => '<img src="images/piicon.png">', 'app' => 'GGP', 'timestamp' => date('m/d/y'), 'location' => 'Bellevue', 'comments' => 'It works!', ), 'id2' => array ( 'icon' => '<img src="images/piicon.png">', 'app' => 'Meijer', 'timestamp' => date('m/d/y'), 'location' => 'San diego', 'comments' => 'It works!', ), 'id3' => array ( 'icon' => '<img src="images/piicon.png">', 'app' => 'Point Inside', 'timestamp' => date('m/d/y'), 'location' => 'Boston', 'comments' => 'I guess its working? Maybe not exactly what we want yet though?!', ) ); echo json_encode($dataArray); ?> Currently if I have 100 results in my array, 100 results will be added to the table, 75 = 75 rows etc. What I am trying to plan out is a logical way to display one result from the array at a time. I am not looking for a chunk of jquery as an answer, better yet would be a plan/idea a programmer would you use to solve this. PHP Code: $(document).ready(function() { setInterval(function() { // get data $.ajax({ url: '/ajax/data.php', type: "GET", cache: false, error: function(data) { $("div#error").html('error: '+data); }, success: function(data) { var jsonObj = jQuery.parseJSON(data); jQuery.each(jsonObj, function(index, value) { var newRow = $("<tr><td>"+value.icon+"</td><td>"+value.app+"</td><td>"+value.timestamp+"</td><td>"+value.location+"</td><td>"+value.comments+"</td></tr>"); $("#mainTable tbody").prepend(newRow); }); } }); }, 5000); }); thanks Hello, I have an array containing 100 different values. How would I randomly pick 25 of them for display? For now I do: PHP Code: for (var i=0; i<markers.length && i<25; i++) { html += markers[i].name + '<br />'; } Which of course returns 25 values but always in the same order which is not what I want. Thanks in advance! PS. My array could also contain only 20 values, in which case I would like the function to display the 20 values randomly sorted. I have an essoteric question about javascript and how DOM/javascript stores divs that are created and displayed in succession by absolute positioning. I have a series of divs that are assigned absolute top and left values to form a grid. The grid tiles are programmed to swap coordinates in pairs when one of the pairs is clicked. Then if I do a sampling of the divs by: Code: //returns the same string on every call. //regardless of the coordinate values. which change var GM = document.getElementById('TP'); if(GM.hasChildNodes) { var GMC = GM.getElementsByTagName('div'); var str = ''; for(i = 0; i < GMC.length; i++) { if(GMC[i].hasChildNodes) { for(var j = 0; j < GMC[i].childNodes.length; j++) { var gmc = GMC[i].childNodes[j]; var gmcTxt = gmc.childNodes[0].data; str += gmcTxt; } } } } alert(str); The list does not represent the positions of the divs as they appear in the browser, but in a sequence that is saved in another array when the divs are created. The same is true for document.getElementById('[id assigned each div]') The only way to detect the sequence is to do a long drawn out loop looking for coordinate values, and comparing them to a prestablish template set of values, then looping back through to compare the contents of each div and decide if they are in the right place (visually). The problem is that some divs may have the same content. If the same content appears to be in the right place, the coordinates can be wrong. So I need to detect the content and decide if it is right, regard- less of the coordinates. This has to be done by the program (of course). So the question is: What is javascript doing when it is asked to Code: document.getElementByTagName('[elem]'); In this case are the divs children of the document? (in the case of my project, children of a container div) And why would they not be detected in the order apparent in the browser window? I will post the current version and return and post a reply with the url. http://www.jekillen.com/jekillen/con..._wise_dev.html Hi, I'm relativly new to JS and brand new to the forum so you might need to dumb down your replys for my slightly lacking knowledge. That being said I do have a very solid grasp of html, css and am getting there with JS and its various frameworks. I'm integrating wordpress into an existing site for a friend and currently have the main blog page appear in a DIV. This is the best way to integrate in this case due to many reasons mostly of way the site is constructed. Code: <div class="scroll-pane" id="scrollbox"> WORDPRESS BLOG </div> My issue is that links within that DIV, in the blog, when clicked redirect the page. The simple answer to this would be to have them just open in a new page, which I can easily do with the below code. Code: function Init() { // Grab the appropriate div theDiv = document.getElementById('scrollbox'); // Grab all of the links inside the div links = theDiv.getElementsByTagName('a'); // Loop through those links and attach the target attribute for (var i=0, len=links.length; i < len; i++) { // the _blank will make the link open in new window links[i].setAttribute('target', '_blank'); } } window.onload = Init; But what I'd rather it do is have any link clicked inside the DIV to reload in that same DIV, similar to an iframe, but obviously without using an iframe, due to it's compatibility issues. Is this possible by editing the above code? If not what do I need? Thanks in advance for any help! On my site I have a Javascript error in my FireBug console: Year is 'null' Code: document.getElementById('year').options[i] = new Option(curr_year-i,curr_year-i); here is my site: http://harveys.blueplanetdns.com/harveys-shop/ Hi guys , How it is possible to get current & next year months and put them into array ..i.e Jan-11 --- M1[0] . . . . Dec-11 M1[11] Jan-12 M2[0] . . . Dec-13 M2[11] thanks |