JavaScript - How To Retrieve Just The Date
I have been able to use javascript to place the last modified date in the bottom left corner of my document however I do not need the time with it.
How do I use the substring() method on the lastModified property? Here is what it looks like. Code: <script type="text/javascript"> <!--Hide from old browsers var today = new Date() var dayofweek = today.toLocaleString() dayLocate = dayofweek.indexOf(",") weekDay = dayofweek.substring(0, dayLocate) newDay = dayofweek.substring() dateLocate= newDay.indexOf(",") monthDate = newDay.substring(0, dateLocate+1) yearLocate = dayofweek.indexOf("2011") year = dayofweek.substr(yearLocate, 4) document.write("<p style='font-family:bold, Arial, Helvetica, sans-serif; font-size:xx-small; color:#000000'>") document.write("Copyright the Huysken Performing Arts Center. ") document.write("<br />This document was last modified "+document.lastModified+"</p>") The text book says to use a substring() method on the lastModified property, but I am uncertain on how to do that. Any help is greatly appreciated, Thank you. Similar TutorialsHi all, I'm using the Epoch calendar at: http://www.javascriptkit.com/script/...ch/index.shtml It works great and does exactly what I need. I'm using it in flat mode so that it can be displayed statically on the page. What I can't seem to work out is how to retrieve the selected date once clicked on. I need to be able to print the output in dd/mm/yyyy format, either on screen or in an alert or something similar. If anyone has worked with this calendar and knows how to do it, or can sort it, I'd appreciate it greatly. I can't paste code here as it's too long, but the source code on the site linked above is exactly the same as I'm using. Cheers! Not sure if this is possible in javascript: I'm looking for two different dates (bill date and due date) on an invoice that are captured by OCR. If one of them exists, but the other does not, I want the empty field to be 14 days before (or after) the other. For example: if the bill date is 7/27/2010 and the due date was not captured, I want to set the due date as 8/10/2010 (14 days after the bill date). If the due date was captured as 8/10/2010, but the due date is blank, I want to assign the bill date as 7/27/2010 (14 days before the due date). if both dates have values, do nothing. Thanks. hi all, as i am very stupid in javascript.... supposing i had a select box on a page with an id of "select1" and name of "select1" as well... using javascript how would i access the select box's selected value and how would i print it out on the screen.... thanks in advance.... cheers sanjeev Hi guys, i need to retrieve the url created in the following script and embed it in the player below. Here is what i have. You can see how it works (and doesn't) here http://www.brittv.co.uk/template.php...ws.stream_360p Code: <html> <head> <title>...</title> <?php $URL_GETKEY="http://www.uktvlive.com/tvc/key.php"; function doCurl($url) { $ch = curl_init($url); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $output = curl_exec($ch); curl_close($ch); return $output; } $a=doCurl($URL_GETKEY); $split=explode("<split>",$a); ?> <script type="text/javascript"> // parse the querystring and create a dictionary of terms for later use: var qs = [ ]; // where the dictionary goes if ( location.search.length > 1 ) { var pairs = location.search.substring(1).split("&"); for ( var p = 0; p < pairs.length; ++p ) { var pair = pairs[p].split("="); qs[pair[0]] = unescape( pair[1] ); } } // do the replacements *after* page is loaded, for simplicity: function doReplacements( ) { var link = document.getElementById("link1"); link.href = "rtsp://81.104.67.230/"+ qs["host"] + "/" + qs["stream"] + "?userID=" + "<?php echo $split[5];?>" + "&accessKey=" + "<?php echo $split[6];?>" + "&sdp=alt&device=mobile"; link.innerHTML = qs["page"]; // and of course you could do any other replacements, too. } window.onload = doReplacements; </script> </head> The following part produces the url Code: <body> <br/><br/> <a id="link1">Generic Link</a> <br/><br/> Lastly we have the player embed code, this is where im stuck im afraid Code: <script type="text/javascript"> var url = qs["link1"]; // or whatever name it was passed by document.write('<OBJECT CLASSID="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" ' + ' WIDTH="300" HEIGHT="160" ' + ' CODEBASE="http://www.apple.com/qtactivex/qtplugin.cab">\n' + '<PARAM name="SRC" VALUE = "http://www.tvpc.com/images/image1.gif" >\n' + '<PARAM name="QTSRC" VALUE = "' + url +'" >\n' + '<PARAM name="HREF" VALUE = "' + url + '" >\n' + '<PARAM name="AUTOPLAY" VALUE = "true" >\n' + '<PARAM name="CONTROLLER" VALUE = "true" >\n' + '<PARAM name="TYPE" VALUE = "video/quicktime" >\n' + '<PARAM name="TARGET" VALUE = "myself" >\n' + '<EMBED \n' + ' SRC = "#" \n' + ' QTSRC = "' + url + '" \n' + ' HREF = "' + url + '" \n' + ' TARGET = "myself"\n' + ' CONTROLLER = "true"\n' + ' WIDTH = "300" \n' + ' HEIGHT = "160" \n' + ' LOOP = "false" \n' + ' AUTOPLAY = "true" \n' + ' PLUGIN = "quicktimeplugin" \n' + ' TYPE = "video/quicktime" \n' + ' CACHE = "false" \n' + ' PLUGINSPAGE= "http://www.apple.com/quicktime/download/" >\n' + '</EMBED>\n' + '</OBJECT>\n' ); </script> </body> </head> Thanks in advance guys Hi guys can help me are very little versed in javascript ... I explain my problem! I have a table where they passed the results of a query ... The table field is called Article and consists of about 500 characters, but the substring in the table with a step the first 40 characters, and now the question arises ... I would click on the text of the article and see the page the entire article ... Code: query="SELECT * FROM Articolo ORDER BY titolo DESC"; ResultSet r = stmt.executeQuery(query); %> <table border="1"> <tr><td> titolo </td> <td> articolo </td> <td> data inser </td></tr> <% while(r.next()) { Tot = r.getString("titolo"); Art = r.getString("articolo"); dat = r.getString("data_inserimento"); String meta = ""; String metadata = ""; meta = Art.substring(0,40); metadata = dat.substring(0, 10); StringBuffer sb = new StringBuffer(meta); sb.replace(37,40, "..."); String s2 = sb.toString(); %> <tr> <td> <%= Tot %> </td> <td> <a href="#" onClick="this.innerText = '<%= Art %>';"><%= s2 %></a> </td> <td> <%= metadata %> </td> </tr> <% } %> </table> I have a drop down menu where people can select a month, day and year. Based on their selection, I want to show them an image. If their selection is >= July 26, 2010 but <= July 25, 2011, show the red image; If their selection is >= July 26, 2011 but <= July 25, 2012, show the white image; If their selection is >= July 26, 2012 but <= July 25, 2013, show the blue image; If their selection is >= July 26, 2013 but <= July 25, 2014, show the yellow image; I don't know how to compare a selected date to a range of dates like this. Hi, I've inherited a Form which calculates a future date based on a calculation and then inserts today's date and the future date into a database. The day part of the date is formatted as a number. This is fine, but up to 9 the numbers display in single figures with no leading zeros. I want them to display leading zeros (e.g. 01, 02, 03, 04, 05, 06, 07, 08, 09, 10, 11... 30, 31) So; 1/12/2010 is NOT wanted 01/12/2010 IS wanted The inherited code originally set the Month names as "Jan", "Feb" etc, and it was easy to kludge these to 01, 02... 12, but I suspect there's a more elgant solution to this as well, this bit of the code works so it's not as vital to neaten this but my database needs dd/mm/yyyy format (it's a third party email program). Code: </script> <script type="text/javascript"> var todaysDate = new Date(); function updateExpiryDate(){ var weeklyMileage = document.getElementById('AvWeeklyMileage').value; var expiryDate; var weeks = 0; var expiryDateString = ''; if (!isNaN(parseInt(weeklyMileage))){ weeks = 700/weeklyMileage; expiryDate = new Date(todaysDate.getTime() + (1000 * 3600 * 24 * 7 * weeks)); var expiryDateString = expiryDate.getDate() + '/' + getMonthString(expiryDate.getMonth()+1) + '/' + expiryDate.getFullYear(); document.getElementById('expiryDate').innerHTML = expiryDateString; document.getElementById('ShoeExpiryDate').value = expiryDateString; } else { document.getElementById('ShoeExpiryDate').value = ''; document.getElementById('expiryDate').innerHTML = 'Please enter a valid weekly average mileage' } } function getMonthString(monthNumber){ var monthString = ""; switch(monthNumber){ case 1: monthString = "01"; break; case 2: monthString = "02"; break; case 3: monthString = "03"; break; case 4: monthString = "04"; break; case 5: monthString = "05"; break; case 6: monthString = "06"; break; case 7: monthString = "07"; break; case 8: monthString = "08"; break; case 9: monthString = "09"; break; case 10: monthString = "10"; break; case 11: monthString = "11"; break; case 12: monthString = "12"; break; default: // do nothing; } return monthString; } function setTodaysDate(){ var todaysDateString = todaysDate.getDate() + '/' + getMonthString(todaysDate.getMonth()+1) + '/' + todaysDate.getFullYear(); document.getElementById('todaysDate').innerHTML =todaysDateString; document.getElementById('DateOfPurchase').value = todaysDateString; } Can someone point me in the right direction please? Hi, I need to add days to a date in javascript, My requirement is as follows: Date is coming from a textbox. eg:- 26/07/2010 days from this statement var day1=document.getElementById('<%=HiddenDate.ClientID %>').value; an eg:- if the date is 28/01/2012 and days Needed to be added=5 the added date should be 02/02/2012. Can anybody help me? Thanks Jamuna Using Adobe Form Javascript validation, how would I do this code for Visual Basic in Javascript (non web) Code: If PurchaseDate.Value > Date Then MsgBox ("PurchaseDate cannot be greater than Today's Date!") Cancel = True End If Something along these lines but this isnt working: Code: If (PurchaseDate.Value > Date) Then { app.alert ("Purchase Date cannot be greater than Today's Date!"); } Thanks Hello, I really need your help with one. How can I use the following code below to save the date from my popup window datepicker back into a var and relay it back onto its parent page? I can't seem to figure this out: Code: <html> <head> <script> function open_cal() { var str_html = "" + "<!DOCTYPE html>\n" + "<html lang=\"en\">\n" + "<head>\n" + "<meta charset=\"utf-8\">\n" + "<title>CALENDAR</title>\n" + "<link href=\"jq/jquery-ui.css\" rel=\"stylesheet\" type=\"text/css\">\n" + "<script src=\"jq/jquery.min.js\" type=\"text/javascript\"></" + "script>\n" + "<script src=\"jq/jquery-ui.min.js\" type=\"text/javascript\"></" + "script>\n" + "<script src=\"jq/datepicker.js\" type=\"text/javascript\"></" + "script>\n" + "</head>\n" + "<body>\n" + "<div id=\"text\" style=\"font: bold 10pt Tahoma\">Enter Approval Date:</div>\n" + "<div id=\"datepicker\"></div>\n" + "</body>\n" + "</html>" var j = window.open("","CALENDAR","width=200,height=250,status=no,resizable=yes,top=200,left=200") j.opener = self; j.document.write(str_html); } </script> </head> <body> <input onclick="open_cal()" type="button" value="Open" name="B1"> </body> </html> Datepicker.js: Code: $(function() { $( "#datepicker" ).datepicker({ dateFormat: 'dd/mm/yy', onSelect: function(dateText, inst) { alert(dateText) window.close() } }) }); Any help with this is greatly and mostly appreciated. Thanks in advance, Cheers, J Hello I am trying to iterate out the values of an xml file. I have got the file to load though I have not yet been able to extract the values. Considering that theXml is an xml file and 'coords' are tags containing a coordinate how would I extract the value. Here is the code I am using Code: var coordTags = theXml.getElementsByTagName( 'coords' ); var len =coordTags.length;///this works var coord =coordTags[0].value;///this doesn't work var coord =coordTags[0].text;///this doesn't work var coord =coordTags[0].innerText;///this doesn't work parent.document.receiver.theres.value = coord; I am sure for some of you this is a really simple question so please someone help!! Hi there I am trying to retrieve xml data using the prototype Ajax.Request. I think I am getting the xml though I am unsure as to how to retrieve the text from the nodes here is the function I am using to try and populate a text field Code: function makeMarkerXml() { new Ajax.Request('coords.xml', { method:'post', onSuccess: function(transport){ ////this will not work///////// var coord = transport.responseXML.childNodes(0).childNodes(0).firstChild.text; /////////////////////////////// }, onFailu function(){ alert('Call failed') } }); } can anyone help? Hello, I'm very new to JavaScript as well as this forum, so apologies if I mess up somewhere. Okay, so I have a HTML doc with a JavaScript attached to it, and in the HTML I have a checkbox. All I want to do is to pass the checkbox data to Javascript as a true/false. Okay, so below is my HTML: Code: <head> <script type="text/javascript" src="java.js"></script> </head> <body> <input id="toggle" type="checkbox" value=""> </body> And this is my JS: Code: var toggleData = false; Now where do I go from here? I tried using getElementByld('toggle'); But no result. I sure would appetite some help here. Thanks Hi, I know there are several ways to do this- but which way is best practice? I can access a variable from one function by making it a global variable, but I read that this isn't the most ideal way, and is a last resort. So for example if I have this: Code: function num1(){ var firstNum = 35; return firstNum; } function num2(){ var secNum = 52; return secNum; } function addNums(x,y){ var f = num1(x); var s = num2(y); var total = f + s; alert(total); } Then I call this function with a button. Now, I know this works, but it doesn't seem like a very good way to do what I'm after. Or is it? Any help/ tips would be great. edit: The idea is that the functions won't just return a single value and that's it. They will return a users choice in a given scenario, so they might return the user's age from the first function, then their location in the next etc etc, then I want to use this information in a separate function. Hi, I have several input text boxes in a <FIELDSET> tag. I would like to load id attributes of the <FIELDSET> tag into an array and then process the array. My code example is below my signature. Thank You in Advance for Your Help, Lou 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" xml:lang="en" lang="en"> <HEAD> <SCRIPT LANGUAGE="JavaScript"> function DisplayDetails(obj_id) { alert("DisplayDetails(" + obj_id + ")"); var form_object = new Array(document.getElementById(obj_id)); var form_elements = form_object.elements; alert(form_object[0]); } </SCRIPT> </HEAD> <BODY> <font size="4" face="Arial" color='Black'> Hi Barney <form> <fieldset id="Person1"> <legend>Person 1:</legend> Name: <input type="text" id="name1" size="30" /><br /> Email: <input type="text" id="email1" size="30" /><br /> Date of birth: <input type="text" id="dob1" size="10" /> </fieldset> </form> </font> <button type="button" onclick="DisplayDetails('name1')">Click Me!</button> </html> So, this is my last problem. If I can nail this, then the website will be completely AJAX driven, and will be spectacular. It took me a while to figure out just how to ask the question. lol Now it is really simple. 1) When I hit the button, in the simplified example below, the website sends a code to the server. 2) The server then re-writes the "xyz.js" JavaScript file with a new array of values. Is there any way to re-retrieve that JavaScript file, from the server to make it the current "xyz.js" rather than the old one that loaded on the client originally. I can get a new XML data file and re-submit that to the website, but how do I re-retrieve the new JavaScript code? Code: <html> <head> <script src="xyz.js" type="text/javascript"></script> </head> <body> <button onclick="onload();">Change</button> </body> </html> Good morning! I am Brazilian, sorry if there is a clerical error because I used the Google translator. I'm having trouble recovering in JS content of the columns of a <TABLE>. I did many searches but found nothing that could help me. I appreciate any help. Thank you! Manoel Zancheta Hello Everyone!!! I have a question, and any advise or help would be greatly appreciated. I know that ANCHORS situated on a page may be retrieved from another page using the method [a href="faq.html#here"]. How would I retrieve an ANCHOR within an IFRAME from another page. Below are my codes. Thank you all in advance, mbay -- [Help Page] <html><body><head><title>Help</title></head><table><tr><td>Below I will show an example of html. For those of you who don't know what HTML is, click <a href="faq_iframe.html#whatis"> here</a></td></tr><tr><td>Below I will show an example of tables. For those of you who don't know what tables are, click <a href="faq_iframe.html#table"> here</a></td></tr><tr><td>Below I will show an example of a hyperlink. For those of you who don't know what HYPERLINK is, click <a href="faq_iframe.html#hyper"> here</a></td></tr></table></body></html> -- [FAQ] <html><body><head><title>FAQ</title> <script language="javascript"> <!-- Hide the script from old browsers -- function surfto(form) { var myindex=form.dest.selectedIndex var passed = form.dest.options[myindex].value var acomma = passed.indexOf(",") var chars = passed.length var filename = passed.substring(0,acomma) var where = passed.substring(acomma+1,chars) if(filename != "") {window.open(filename, rel="nofollow" target=where)}; } //--> </script> </head><table><tr><td><form name="myform"><select class="pulldown" name="dest" size="1"><option>Select An Option</option><option value="faq_iframe.html#whatis,FAQ">What is HTML</option><option value="faq_iframe.html#table,FAQ">What are tables?</option><option value="faq_iframe.html#hyper,FAQ">What are hyperlinks?</option></select> <input type="button" value="GO!" onclick="surfto(this.form)"></form></td></tr><tr><td><IFRAME SRC="faq_iframe.html" Title="FAQ" SCROLLING="auto" NAME="FAQ" WIDTH="200" HEIGHT="200" ALIGN="center" FRAMEBORDER="no" style="border:15px ridge #0066FF"></IFRAME></td></tr></table></body></html> -- [FAQ IFRAME] <html><body><head><title>FAQ IFRAME</title></head><table><tr><td><font size="7">Welcome to the FAQ SECTION</font></td></tr><tr><td><a name="whatis"><b>What is Html?</b></a></td></tr><tr><td>HTML ( H yper T ext M arkup L anguage) is the language used to write Web pages. You are looking at a Web page right now. </td></tr><tr><td><a name="table"><b>What are tables?</b></a></td></tr><tr><td>Think of your tabular information in light of the coding explained below. A table has heads where you explain what the columns/rows include, rows for information, cells for each item. In the following table, the first column contains the header information, each row explains an HTML table tag, and each cell contains a paired tag or an explanation of the tag's function. </td></tr><tr><td><a name="hyper"><b>What are hyperlinks?</b></a></td></tr><tr><td>Hyperlinks are what connect the world wide web, without them we would get nowhere without knowing the exact URL (Universal Resource Locater) of the document we are looking for. Hyperlinks or more commonly just called "links" can do many things, but they always call for an action. A link could open your email client, it can move you to different pages or it can move you to different spots within the same document. </td></tr></table></body></html> |