JavaScript - Image Format
I came across this really interesting experiment.
http://www.romancortes.com/blog/a-tr...o-the-beatles/ What I was wondering was does anyone know what the data used is from? I mean what type of image format it is. I've tried to figure it out but I just can't find what it is. I see how the script works, but I was wondering if the author used some available image format or if he created the image data from scratch. Thanks for any advice you might be able to offer. Similar TutorialsI am trying to get my script working in FF, IE and Opera but the getAttribute isn't working for me. The domain name isn't getting picked up I have tried this: var dom_name = document.getElementById('dom_nm').getAttribute("value",2); and this: var dom_name = document.getElementById('dom_nm').getAttribute('value'); After this I use the domain name like this: Code: if (per2 == 0) { item_desc = "Domain Name and DNS set up. Domain: "+dom_name+" Period: "+per1+"year"+" No Privacy."; } if (per2 > 0){ item_desc = "Domain Name and DNS set up. Domain: "+dom_name+" Period: "+per1+"year"+" Including: Privacy: "+per2+"year."; } document.getElementById('item_pay').setAttribute("value","item_desc"); ( I also tried: Code: document.getElementById('item_pay').setAttribute('value') = item_desc; but that didn't seem to work either ) The HTML is like this: Code: <div style="margin: 5px auto;"> <table> <th>Your New Domain Name Order</th> <tr><td>Product</td><td>Cost</td><td>Years (max. 10)</td><td style="text-align: right;">Total Cost</td></tr> <tr><td id="dom_nm" value="John.Doe"><?php echo "Domain: $N_dom.$N_tld" ?></td><td id="price" value = '<?php echo "$priceN" ?>' ><?php echo $priceN ?></td><td><input style="background-color: yellow; font-weight: bold;" type='TEXT' id="per_1" size = '10' value = '<?php echo "$period_1" ?>' ></td><td><input type='TEXT' id="total_1" style="text-align: right;" value = '<?php echo "$total_1" ?>'></td></tr> <tr><td>Domain Privacy</td><td>8.70</td><td><input style="background-color: yellow; font-weight: bold;" type='TEXT' id="per_2" size = '10' value = '<?php echo "$period_2" ?>'></td><td><input type='TEXT' id="total_2" style="text-align: right;" value = '<?php echo "$total_2" ?>'></td></tr> <tr><td>Total Order.</td><td> --- </td><td> --- </td><td><input type='TEXT' id="total_3" style="text-align: right; font-weight: bold;" value = '<?php echo "$total_3" ?>'></td></tr> </table> </div> The result is that I get a zero ( 0 ) where the domain should be. Like this: Domain Name and DNS set up. Domain: 0 Period: 2year Including: Privacy: 2year. Plus Free Blog Install. Any ideas what I am doing wrong ? Thanks Hi all, I have a web form. I use a simple function to generate a letter ouput based on the form fields and populate them into a word doc for printing. Below is a basic example, but you get the idea. Code: function createDocument() { strDoc = "\n\n" strDoc += "Hello there!\n" strDoc += "Answers to form stuff goes here\n" var w =new ActiveXObject("Word.Application"); w.Visible=true; w.Documents.Add(); w.Selection.TypeText("" + strDoc); } Note this is only intended to be used on IE8. As it stands, the ouput generates and formats exactly as I want bar two things: 1) Does anyone know how I can get some of the text to bold? I've tried everything I can think of (html tags, escape characters etc etc). Is there a way to open a word window in rtf perhaps? 2) Does anyone know how I can insert a small image (a signature in gif or jpg) into the document? I can use a browser window instead of word, which formats, bolds, images etc, however I then get the issue of headers/footers when printing. I cannot disable headers everytime I want to print a letter, it's not practical. Any advice would be greatly appreciated Cheers! I've been trying to change the way a date appears. The JS gives the date Easter will fall in a particular year. That works but the format that appears is this; Sun Apr 24 00:00:00 EDT 2011 I'm trying to get it to read like this: Sunday, April 24, 2011 I've been racking my brain all morning and can't seem to get it right. Very limited experience in JS doesn't help either. Could somebody take a look and see where I messed up. Thanks in advance. George Code: easterYear = 2011; var a, b, c, d, e, f, g, h, i, k, l, m, easterMonth, easterDate; a = parseInt(easterYear % 19); b = parseInt(easterYear / 100); c = parseInt(easterYear % 100); d = parseInt(b / 4); e = parseInt(b % 4); f = parseInt((b + 8) / 25); g = parseInt((b - f + 1) / 3); h = parseInt((19 * a + b - d - g + 15) % 30); i = parseInt(c / 4); k = parseInt(c % 4); l = parseInt((32 + 2 * e + 2 * i - h - k) % 7); m = parseInt((a + 11 * h + 22 * l) / 451); easterMonth = parseInt((h + l - 7 * m + 114) / 31); easterDate = parseInt(((h + l - 7 * m + 114) % 31) + 1); var dayName = new Array ("Sunday","Monday","Tuesday","Wednesday", "Thursday","Friday","Saturday"); var monthName=new Array ("January","February","March","April","May", "June","July","August","September","October", "November","December"); var now = new Date(); var gplMonth = monthName[easterMonth-1]; var gplDay = dayName[0]; //gplDay ; var gplDate = new Date(); var gplDt = gplDate.getDate(); document.write(new Date(easterYear , easterMonth - 1, easterDate) ); // Original line document.write('<br />' ) document.write( gplDay + ", " + gplMonth + " " + easterDate + ", " + easterYear) document.write('<br />' ) document.write(gplMonth + " " + easterDate ) document.write('<br />' ) Dear Experts I have following codes Code: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <meta name="language" content="english"> <meta http-equiv="Content-Style-Type" content="text/css"> <title>Numeric Textbox Sample</title> <style type="text/css"> #box1 {width:200px;height:170px;border:1px solid green;background:#e3eeff;padding-top:20px;} .button {width:100px;margin-top:0px;} body { margin:0; margin-top:100px; } </style> <script language="javascript"> function NumericDotOnly() { var key = window.event.keyCode; if (((key >47) && (key <58)) || (key==46)) window.event.returnValue = true; else window.event.returnValue = false; } function formatCurrency(num) { num = num.toString().replace(/\$|\,/g,''); if(isNaN(num)) num = "0"; sign = (num == (num = Math.abs(num))); num = Math.floor(num*100+0.50000000001); cents = num%100; num = Math.floor(num/100).toString(); if(cents<10) cents = "0" + cents; for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++) num = num.substring(0,num.length-(4*i+3))+','+ num.substring(num.length-(4*i+3)); return (((sign)?'':'-') + num + '.' + cents); } </script> </head> <body onload="form2.text1.focus()" > <center> <p>I need following format<br> 99,999,999.99<br> </p> <div id="box1"> <form name=form2> <table width="100%" border="0" cellpadding="0" cellspacing="0"> <tr><td>Amount</td> <td><input type=text name=text1 size=15 value="" onkeypress="NumericDotOnly ()";onblur="formatCurrency(this.value)"> </td></tr> <tr><td>Tax</td> <td><input type=text name=text2 size=15 value="" onkeypress="NumericDotOnly()";onblur="formatCurrency(this.value)"></td></tr> <tr><td>Result</td><td><input type=text name=text3 size=15 value="" disabled></td></tr> </table> <hr> <input class="button" type=button name=command1 value="Plus" onclick="form2.text3.value=parseFloat(form2.text1.value)+parseFloat(form2.text2.value)"><br> <input class="button" type=button name=command8 value="Focus" onclick="form2.text1.select()";"form2.text1.focus()"><br> <input class="button" type=reset name=command9 value="Reset"> </form> </div> </center> </body> </html> Please help me to apply following format 99,999,999.99 Thanks in advance hey all - new to the forum, and need some quick help. i have a form with multiple data entry fields, one of which i need to be in a certain format. currently it will only check for total length (17 digits), which is part of it, but the format needs to be exactly: 0000-00000-000000 (where zeros are numbers) the best thing would be if when the user enters 15 digits, it would automatically format it with the dashes. any and all help is appreciated. please note: this is being used for a print solutions software that auto-generates most of the code, we cannot rewrite all of the code, only work with what we have. here is the code: Code: if (Form1.elements['EIF2']){ if(Form1.elements['EIF2'].disabled == false){ if (!CheckEntry('EIF2', 'Lawson # ', true, 17, 'exactly'))return false; } We format euro currency as 1.000.000,00 (just the opposite of USD). Anyone who could give me a script that changes the input into this format? I tried 'replace' with a regular expression, but my regexes don't work. Hello! First of all, sorry my bad english. (and javascripting skills...) I have a problem with date formatting! My code is supposed to get the day of the week from date format like dd.mm.yyyy (01.01.2010, 31.12.2010) but it only works if date format is like "28 December, 2000". Code is he Code: <script type="text/javascript"> function getTheDay(aText) { myDays=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"] myDate=new Date(eval('"'+aText.value+'"')) document.form1.textDay.value=myDays[myDate.getDay()] } </script> <form name="form1" id="form1" method="post" action="" enctype="text/plain"> <input type="text" name="textDate" id="textDate" value="" size="25" onchange="getTheDay(this.form.textDate)" /> <br /> <input type="text" name="textDay" size="25" maxlength="25" /> </form> Original code: http://www.trans4mind.com/personal_d...ript/time2.htm Can anyone help me? I have tried everything what i have find from google... Thanks to you all who help me with this! -Roosterr Hello. I have got this kind of array: Code: $days = array('Monday' => '2012-03-19', 'Tuesday' => '2012-03-20' ); I'm iterating like this: Code: foreach($days as $key => $value){ echo '<a href="javascipt:confirmDelete('.$value.');">Delete</a>'; } Script: Code: function confirmDelete(day) { if (confirm('Delete?')) { window.location.href = 'processDay.php?action=delete&day=' + day ; } } While i hover over the link with coursor, it show it good: javascript:confirmDelete(2012-03-19), but when I submit the delete confirmation, i get &day=1987. Where is the problem? Alright so I've been searching around trying to figure out how to change the date format, the way I have seen it the most is like Code: var d=new Date(); var datestring=d.getdate + d.getMonth + d.get Year I am new to javascript and this is the first script I have written on my own so this is what it does. It is supposed to display the date that a shipment should arrive on with 2 day shipping through ups so it skips weekends. It displays the date after either adding 2 days or more depending on the day of the week. But the way the date is formatted really needs to be changed. So if any one can suggest maybe how to tie in the above code with mine that would be great. Code: <script type="text/javascript"> var d=new Date(); var day=d.getDay(); if (day <= 3){ d.setDate (d.getDate() + 2); } else if (day == 4) { d.setDate (d.getDate() + 4) } else if (day == 5){ d.setDate (d.getDate() + 4); } else if (day == 6) { d.setDate (d.getDate() + 3); } document.write("Your card should arrive on " + d); </script> Is there a built in function to format a number to 2 decimal places and to add commas like below. 2,222.33 30,033.98 1,222,345,99 Hi, I have a textarea element and I fill it with text. But I want to insert newlines to seperate some of the words in the textarea. I tried to use '\r' or '\n' or '\r\n', but none of them works. Code: var textArea = document.createElement('textarea'); textArea.value = 'good' + '\n' + 'morning'; The newline has no effect, it still show 'good morning'. Why? And also, I am going to write these words in the textarea into database and later retrieve them back from database to another textarea, should I keep the newline characters or is it better use some other delimiter? Many thanks. i try to create a simple editor. But i'm having problem with bullets hierarchy Code: <html> <body> <style type="text/css"> #preview,#editor,#editor-html{ width:500px; height:250px;} #preview{ clear:both;background:#eee; } #editor,#editor-html{ float:left;} </style> <div id="preview"></div> <p><textarea id="editor" ></textarea></p> <p><textarea id="editor-html"></textarea></p> <script type="text/javascript"> var oEdit = document.getElementById('editor'); var oCheck = document.getElementById('editor-html'); var oPrev = document.getElementById('preview'); function doBullets(s){ var s = this.value; var r = /\n{2}\s#\s[\s\S.]*?\n{2}/g; var a = s.match(r); var step = 0; var bCount = false; if(a){ a = a.toString(); a = a.split(/\n{2}/g); var iL = 0; var iMax = 0; for(var j=0;j<a.length;j++){ if(a[j].match(/^\s#\s/)){ var iF = s.indexOf(a[j]); var iL = a[j].length; var html = ''; var list = a[j].split(/\s#/); for(var i=0;i<list.length;i++){ if(list[i]){ var level = list[i].match(/^\s?#*\s/); level = level?(level[0].length):0; var txt = list[i].replace(/^\s?#*\s/,'').toString().replace(/\n?$/,''); if(level > step){ step++; iMax++; html = html.replace(/<\/li>\n?$/,''); html += '\n<ul>\n'; } if(level < step){ step--; html += '</ul>\n'; } var iCounter = iMax-level; if(iCounter){ for(var y=0;y<iCounter-1;y++){ html += '</li></ul></li>'; } } document.title = level+' '+step+' '+iMax+' counter:'+iCounter; html += '<li>'+txt+'</li>\n'; } } s = s.substring(0,iF)+html+s.substring(iF+iL,s.length); } } } oPrev.innerHTML = s; oCheck.value = s; } oEdit.onkeyup = doBullets; </script> </body> </html> Please help... Hello, I want to change time format from 12 to 24 hours and remove AM and PM in this script. Anybody can help me? Code: <style type="text/css"> /*<![CDATA[*/ #clock { font-family: "Trebuchet MS", Arial, Helvetica, sans-serif; font-size:16px; color:#030; padding-top: 24px; text-align:center; } /*//]]>*/ </style> <script type='text/javascript'> //<![CDATA[ var dayarray=new Array('Svē','Pir','Otr','Tre','Cet','Pie','Ses'); var montharray=new Array('01','02','03','04','05','06','07','08','09','10','11','12'); function getthedate(){ mydate=new Date(); year=mydate.getUTCFullYear(); day=mydate.getDay(); month=mydate.getMonth(); daym=mydate.getDate(); if(daym<10) { daym='0'+daym; } hours=mydate.getHours(); minutes=mydate.getMinutes(); seconds=mydate.getSeconds(); dn='AM'; if(hours>=12) { dn='PM'; } dn='AM'; if(hours>=12) { dn='PM'; } if(hours>12){ hours=hours-12; } if(hours==0){ hours=12; } if(minutes<=9) { minutes='0'+minutes; } if(seconds<=9) { seconds='0'+seconds; } cdate=dayarray[day]+', '+daym+'-'+montharray[month]+'-'+year+', '+hours+':'+minutes+':'+seconds+' '+dn; document.getElementById('clock').firstChild.nodeValue=cdate; setTimeout('getthedate()',1000); } window.onload=function() { getthedate(); } //]]> </script> Thanks. Hi All, I have a snippet of Javascript that changes date format from yyyy/mm/dd to dd/mm/yyyy: Code: <script type="text/javascript"> var myString = "[[date]]"; var mySplitResult = myString.split("-");document.write(mySplitResult[2] + "/" + mySplitResult[1] + "/" + mySplitResult[0] ); </script> However, I want it to return the format as dd/mm/yy (the last two number of the year rather than the full four). Is this possible to do? Thanks, Neil Hello, I am using jQuery to set a cookie and the expiration date is: Code: date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000)); which lasts for 1 day, but I would like the cookie to not expire for a long time, is this possible? I know google has one that like expires in 2035 or something but I would like this on to last long. What should I do? Does JavaScript have an easy of converting an ordinary integer like 135 into a time format like 02:15? I'm working on a timer that handles the backend with just a plain integer that counts down every second but it needs to output looking like a clock.
1. I previously made some pages in which had audio controls which worked when I actually ran them. However I have now moved these pages to another folder location but now they do not work, when I run the page the buttons appear as if they have already been clicked and appear "stuck", i've tried to manually change the URL location of the audio file my self and the button becomes "unstuck and I can press it but still I hear no audio. I would like to know if possible what is going on The controller settings with url before I changed it- <embed src="../Sounds/home_page_readout.wma" width="405" hidden="false" height="39" autoplay="false" controller="true"></embed> 2. Secondly I would like to know how to get different media formats to work on different browsers. Hello, Firstly - relatively new to javascript. I have seen many examples of code that will return a passed value in a currency format - however I have a sales form that is calculating values via a function in the text boxes I want formatted with a currency ($) symbol. The function that is called is not passing any values, and returning a calculation of the form subtotals per item, and then total sales figure. Can anybody give me any hints on format these cells to a currency value? I can give examples of how my code is currently if required. Thanks in advance I'm trying to add some css tags (<strong>, <em> etc) to an entire paragraph <p> that contains a custom word, for example a paragraph like this <p>Title:....</p> This could be easily done for the custom word only with a var.str and document write. I would be grateful if you could post the entire code. I'm not too sure how to approach this but I have a date input that uses a jQuery pop-up for a calendar, and enters the date in a format d MMM yy (1 Jan 11). Not everyone wants to be clicking and choosing the date from the calendar but to be entering it just as a number such as 0101, 010111 or 01012011 which can be faster. This would then need to be converted to the d MMM yy format as per the jQuery pop-up when they exit the input box. So really only if it's a number format it needs to look at the number of digits... and does the conversion. Has anyone done something like this before? Or is there a link to how I could go about achieving this? Many thanks David |