JavaScript - Need Help In Creating A Script
Hi, my name is Joe.
I have no expierience in writting scripts buy have managed to put together what I think is a decent website for a local business. It is a local Bait & Tackle shop. I have done this for free as I am retired and work a few days a week in the owners shop. This is my situation. I wish to display the current days high tides in a web page. I have created a database (csv file) which resides on my server This file has two fields: date and tidal times I am looking for a script that test the "date" field and if it is equal to the current date, display the tidal field. Any help would be appreciated. Thanks, Similar TutorialsI have searched and scoured the web looking for a script like this. I have found different scripts that do certain aspects of what I am looking for, but not ONE that does it all. I am hoping you can help bring my search to an end! I need a script that when a user tries to leave a page, either by typing in a URL in the address bar or clicking an external link they get a Javascript (not pop up window) dialog box asking if they would like to complete a survey. If they click OK they are then redirected to the survey page. If they click cancel it allows them to go on their way to the external link. It needs to be able to decipher between internal and external links. The script needs to work with both IE and FF. This is a must. Safari would be a plus. I would like, BUT IS IN NO WAY A NECESSITY, for the script to also be cookie based in that the user doesn't see it if they've seen it within 7 or 14 days. I really hope you all can help me here as I am lost! If you need any other info from me please let me know! What is best for creating a PTC script
I am trying to create a text area input filed for user input, and i want to be able to allow the user to format thier text, just like the ones used in this user forum. I am writing my website in html, php, javascript and css with a MySql database. I am trying to understand how to create such an format-able text area for input. Any ideas? Thank you; Ice I'm trying to get my Client Side Firefox DHTML app to display a list of eBooks. For this, i have the following files F:\Textbooks.html F:\eBooks.txt F:\FirstBook.txt F:\SecondBook.txt F:\ThirdBook.txt textbooks.html is my DHTML app eBooks.txt is the Library file with a listing of all of my eBooks. Inside of eBooks.txt is the following data: ----------------- FirstBook.txt, SecondBook.txt, ThirdBook.txt, ----------------- FirstBook.txt to ThirdBook.txt are my actual ebooks. The problem that i'm having is that When i try to click on any buttons other than the FirstBook button, i get the following error: ---------------------------------- Error: unterminated string literal Source File: file:///F:/Textbooks.html Line: 1, Column: 10 Source Code: LoadEbook(' ---------------------------------- So, unlike clicking on the FirstBook button, these other buttons do not load the eBook data into the DIV for displaying the eBook data. I use the DOM insepector to checkout the DOM of the button code, and it seems like whitespace maybe is the problem. However, i have removed whitespace from the HTMLdata string, and that's not fixing the problem. did i forget something silly? LOL i'm using FireFox 3.5 to develop this App. So obviously this will not work with anything other than Gecko Based browsers. here is my HTML code: <html> <head> <script language="JavaScript"> var eBookLibrary = "eBooks.txt"; var SystemPath = "f:" + String.fromCharCode(92) function Init() { // Initialize the eBook reader document.getElementById("EbookCanvas").style.visibility = "hidden"; document.getElementById("EbookToolbar").style.visibility = "visible"; document.getElementById("FileManager").style.visibility = "visible"; // Load the List of eBooks in the Library LoadBookList(); } function UpdateEbookList() { // Update the Library of Ebooks alert("Updating eBook Library"); // Go back to the File Manager, and Reload the List of Ebooks LoadBookList(); } function LoadBookList() { // This will load the list of books that are available var EbookList = LoadFromDisk(SystemPath + eBookLibrary); var EbookListArray = EbookList.split(","); for(var x = 0; x < EbookListArray.length -1; x++) { // Strip the Filename Extension off of the eBook File Name // The Name of the Book is always the first Index in the Array var BookName = EbookListArray[x].split("."); // Remove the weird whitespace - it screws things up...i think... BookName[0] = BookName[0].replace(/(^\s*|\s*$)/g, ""); var HTMLdata = HTMLdata + "<input type='button' value='" + "FirstBook" + "'" + " onClick=LoadEbook('" + EbookListArray[x] + "');><br>"; } // For some ****ed up reason the first string always generates an 'undefined' even though it's nonsense // So just delete that from the HTMLdata string, because it's just ugly - LOL HTMLdata = HTMLdata.replace("undefined", ""); HTMLdata = HTMLdata.replace("", " "); // Write the HTML data to the DIV document.getElementById("FileManager").innerHTML = HTMLdata; } function LoadEbook(EbookName) { // Hide the File Manager and Show the Ebook Canvas document.getElementById("FileManager").style.visibility = "hidden"; document.getElementById("EbookCanvas").style.visibility = "visible"; document.getElementById("EbookToolbar").style.visibility = "visible"; // Load the Ebook content into the Ebook Reader Pannel var EbookContent = LoadFromDisk(SystemPath + EbookName); document.getElementById("EbookCanvas").innerHTML = EbookContent; } function LoadFromDisk(filePath) { if(window.Components) try { netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); var file = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile); file.initWithPath(filePath); if (!file.exists()) return(null); var inputStream = Components.classes["@mozilla.org/network/file-input-stream;1"].createInstance(Components.interfaces.nsIFileInputStream); inputStream.init(file, 0x01, 00004, null); var sInputStream = Components.classes["@mozilla.org/scriptableinputstream;1"].createInstance(Components.interfaces.nsIScriptableInputStream); sInputStream.init(inputStream); return(sInputStream.read(sInputStream.available())); } catch(e) { //alert("Exception while attempting to load\n\n" + e); return(false); } return(null); } </script> </head> <body onLoad="Init();"> <div id="FileManager" style="position: absolute; top: 0px; left: 0px; visibility: visible;"> The eBook Library's List of Books will be listed here. Click on one to open it in the eBook Reader </div> <br> <div id="EbookCanvas" style="position: absolute; top: 0px; left: 0px; visibility: hidden;"> </div> <br> <div id="EbookToolbar" style="position: absolute; top: 100px; left: 0px;"> <input type="button" value="Open" OnClick="Init();"> <input type="button" value="Update" OnClick="UpdateEbookList();"> <input type="button" value="Exit" OnClick="MainMenu();"> </div> </body> </html> Hi All, I have two scripts which I want to try and integrate. I am using a nice gallery script to show thumbnails which are appended to a an image wrapper which on click of the thumbnail shows the larger image in the image wrapper, I am trying to implement cloud zoom which is a plugin which uses image srcs to then point to an anchor href to show another larger zoom image either in the same place.. which is what I am trying to do or in another div beside. I have had to set me img srcs up in a certain way to easily enter some product details. and I need to try an manipulate the code to make it work to suit my file layout. I am using a var= images [ with a series of file locations and info such as below { src: 'romanticabride/thumbs/tn_Shauna.jpg', srcBig: 'romanticabride/images/Shauna.jpg', title: 'Shauna', longDescription: '<b><H1>Shauna</H1></b><br><b>Romantica Of Devon <br><br><h2>Sizes Available:</h2><br> 6 - 32.<b><br><b><br><b><b><b><H2>Colours Available:</h2><b><br>Various<br>Please Enquire Below<br><br><br><br><a href="mailto:tracy@cherishbridal.co.uk?subject=Web Enquiry Regarding Romantica Shauna Bridal Gown"class="enquiry rose glow" >Click To Enquire About This Item </a>' }, what I need is for cloud zoom to work when the main image wrapper is hovered over which means it will need to add a class or when the whichever srcBig: is hovered over it gets wrapped by href to make the script work . one of my pages is http://www.cherishbridal.co.uk/romaticabride.html the cloud zoom script is at http://www.professorcloud.com/mainsite/cloud-zoom.htm.. I am happy to share a jsfiddle with someone or explain further or post some code. Thank you in advance does any expert know how to pass parameters in the <script ..> tag? for instance; Code: <script type="text/javascript" src="script.js ?param1=val1¶m2=val2&etc "> in the javascript script.js, how would we read the params after the question mark? for example, google this; google shopping cart /v2_2/cart.js I have a script that works in seamonkey(my html editor) but when I use it in IE8 it says errors happen. Here's the code (the first line is on line 7 of the html file): Code: <script type="text/javascript"> function enlarge(imageNum) { var numToString = ""; if(parseInt(imageNum) < 10){ numToString = "0" + imageNum; } else { numToString = imageNum + ""; } window.open("images/LgScreenshot"+numToString+".jpg","Screenshot "+imageNum,"status=0,height=675,width=900,resizable=0"); } </script> And the errors: Webpage error details User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0; GTB0.0; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.5.30729; InfoPath.3; .NET CLR 3.0.30729) Timestamp: Wed, 10 Feb 2010 14:58:16 UTC Message: Object expected Line: 150 Char: 1 Code: 0 URI: http://samssc2site.co.cc/Features.html Message: Invalid argument. Line: 18 Char: 1 Code: 0 URI: http://samssc2site.co.cc/Features.html I need to assign a key in the javascript to actually make the javascript work,. I have a bookmark in chrome , a javascript , which actually works when clicked on it .,. but how can i edit it so that i can actually make it work on click a key or combination of keys. i want to declare the key or keycombo in the script itself .,. the script is for catching the selected text on the webpage and opening a new tab(or window) and doing an exact search search of the selected text using google.com .,., So I want it to work it this way ., select the text press a key and it opens a new tab (or window) with an xact search .,. i want to declare the key or keycombo in the script itself .,. the script is for catching the selected text on the webpage and opening a new tab(or window) and doing an exact search search of the selected text using google.com .,., So I want it to work it this way ., select the text press a key and it opens a new tab (or window) with an xact search .,. Thanks in advance ., Nani On this website: http://evancoleman.net/index.php I really like on the top how the menu has like 5 or 6 icons, and when you hover over them it shows a bubble with the name in them. Does anybody know where I can find this script? Thanks. Hi i am looking to create a js pop up to display an amazon widget which relates to an item on my page. so i've found this on the net http://blazonry.com/javascript/windows.php but im not very javascript minded and dont know where to start. so i have tried this Code: <img src="images/listen.png" border="0" alt="Preview Songs" title="Preview Songs" onclick="window.open("song_preview.php?id=<?php echo $row['ASIN']?>","Window1","menubar=no,width=430,height=360,toolbar=no");" /> but it loads a blank pop up at the same time the page loads up and not when an image is clicked? plus when i first loaded the page it said pop up blocked which sucks!! on the example i didnt get that, any reason why??? any help is appreciated thanks Luke i need to create a div as i click down and move while pressing the mouse button and the div will increase in size as i move the mouse while still pressing the mouse button. how can i accomplish this task I have asked to create a chatbox, which acts just like a messenger which I type a text in the textbox and press send to show output to the messagebox. However, in my code, I have 2 bugs which is bothering me. The first one is whenever I press spacebar, a "+" sign appear. The second is the first text disappeared whenever I type the second text. Please help me. Code: <html> <head> <title>Untitled</title> <script language="JavaScript" type="text/javascript"> <!-- var isShift=null; var isNN = (navigator.appName.indexOf("Netscape")!=-1); var OP = (navigator.appName.indexOf("Opera")!=-1); if(OP)isNN=true; var key; function shift(event){ key = (isNN) ? event.which : event.keyCode; if (key==16)isShift=1; } function process(event){ key = (isNN) ? event.which : event.keyCode; if(document.layers&&event.modifiers==4){ isShift=1; } if (key==13&&isShift!=1){ document.myForm.submit(); } if (key!=16)isShift=null; } function retrieve(){ document.myForm.text1.focus(); if(location.search.length>0){ blubb=unescape(location.search.split('=')[1]); document.myForm2.text2.value=blubb; } } //--> </script> </head> <body onload="retrieve()"> <form name="myForm"> <textarea name="text1" onkeypress="process(event)" onkeydown="shift(event)" cols="50" rows="7"></textarea><input type="submit" accesskey="s" value="Send"> </form><br><br> This second textarea is just to show, that the line breaks "arrive":<br> <form name="myForm2"> <textarea name="text2" cols="50" rows="7"></textarea> </form> </body> </html> Hey All, I've currently working on making a calendar for my website. How do I go about creating a password for it? So that the admin can add events to it. Cheers Guys!!! Alright I have never really created a class before and I have to for a project. This is what I have so far and I will try to explain the requirements I am looking for thoroughly and what problems I am having. Code: <!doctype html public "-//w3c//dtd html 4.0 transitional//en"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <script language="javascript" type="text/javascript"> function clock () { //Object Constructor this.setT = function() { //Method Set Time //Properties this.currentTime = new Date ( ); this.currentHours = this.currentTime.getHours ( ); this.currentMinutes = this.currentTime.getMinutes ( ); this.currentSeconds = this.currentTime.getSeconds ( ); } clock.prototype.displayTime = function () { clock.setT } } </script> <body> <form name="form1"> <p> <input type="text" rows=7 cols=60 name="currentTime"> <br> <input type="button" value="Set Time" onClick="clock.displayTime();"> <br> <input type="button" value="Display Time" onClick="currentTime.value= completeTime;"> <br> <input type="reset" value="Reset"> </p> </form> </body> </html> The clock class contains: Three Properties: Hours Minutes, Seconds Two Methods setTime (which uses date class to get current time) Must be defined in the constructor displayTime (returns a string displaying current time) Must be defined as a prototype property of constructor The below is a very rough outline, and probably not correct. I've been reading up on objects for the last few hours and can't be very sure of anything yet. Code: function clock() { this.currentTime = new Date ( ); var currentHours = currentTime.getHours ( ); var currentMinutes = currentTime.getMinutes ( ); var currentSeconds = currentTime.getSeconds ( ); this.setTime = function() { } } clock.prototype.displayTime = function ( ) { } I guess my biggest problem now is the outline. Any help would be great hopefully once i get what goes where i can actually start writing the code. I already have the full code to write a basic clock just like this but it doesn't use classes or any of this. So yeah, I'm making a science fair project, and need to know if someone could make the script below work into being invincible. Code: <Style Type="Text/CSS"> <!-- Input{} .blokje{ Height:48px; Width:48px; Font-Size:16pt; Font-Weight:900; Font-Family:Comic Sans MS,Arial,Verdana; Text-Align:Center; } .knopje{ Width:144px; } --> </Style> </HEAD> <!-- STEP TWO: Copy this code into the BODY of your HTML document --> <BODY> <!-- This script and many more are available free online at --> <!-- The JavaScript Source!! http://javascript.internet.com --> <!-- Original: Rob van der Ven (vennie@wanadoo.nl) --> <!-- Web Site: http://home.wanadoo.nl/vennie --> <Center> <Form> <Input Type="Button" Title="Click here to play again" Name="beurten" Width="164px" Class="knopje" Value="Player 1" onClick="wie = 'Player 1'; initieer()"> <Table CellPadding="0" CellSpacing="0" Border="0"> <Script Language="JavaScript"> <!--// for (i = 1; i < 10; i++) { if (i % 3 == 1) {document.write('<Tr>');} document.write('<Td><Input Type="Button" Name="' + i + '" Value=" " Class="blokje" onClick="wijzig(this.form,this)"></Td>'); if (i % 3 == 0) {document.write('</Tr>');} } //--> </Script> </Table> <Input Type="CheckBox" Title="Click here to change from 2 players or computergame" Name="automaat" Value="2 players" Id="autmat" onClick="if (this.value == 'Computer') {this.value = '2 players'; auto = 0} else {this.value = 'Computer'; auto = 1}; wie = 'Player 1'; initieer();"><Label For="autmat">against the computer</Label> <Table CellPadding="0" CellSpacing="0" Border="1"> <Tr BgColor="Silver"> <Td Align="Center"> Player 1 </Td> <Td Align="Center"> Player 2 </Td> <Td Align="Center"> Tie </Td> </Tr> <Tr BgColor="Silver"> <Td Align="Center"><Input Style="BackGround-Color:Transparent;Border:Solid 0px;Text-Align:Center" Type="Text" Size="3" ReadOnly Title="Player 1" Name="speler1" Value="0"></Td> <Td Align="Center"><Input Style="BackGround-Color:Transparent;Border:Solid 0px;Text-Align:Center" Type="Text" Size="3" ReadOnly Title="Player 2" Name="speler2" Value="0"></Td> <Td Align="Center"><Input Style="BackGround-Color:Transparent;Border:Solid 0px;Text-Align:Center" Type="Text" Size="3" ReadOnly Title="Tie" Name="Tie" Value="0"></Td> </Tr> </Table> </Form> </Center> <Script Language="JavaScript"> <!--// timerID = xtal = ytal = ztal = auto = 0; wie = 'Player 1'; function initieer(){ clearTimeout(timerID); cel = new Array(0,0,0,0,0,0,0,0,0,0); aanv = new Array(); strat = verd = leeg = aanv; beurt = wissel = 1; wint = keren = 0; document.forms[0].speler1.value = xtal; document.forms[0].speler2.value = ytal; document.forms[0].tie.value = ztal; if (wie != 'Start') { for (i in cel) { cel[i] = 0; if (i > 0) {document.forms[0].elements[i].value = ''}; } } document.forms[0].beurten.value = wie; } function zetten() { clearTimeout(timerID); if (aanv[0] > 0) { slag = aanv[Math.floor(Math.random() * 10) % aanv.length] } else if (verd[0] > 0) { slag = verd[Math.floor(Math.random() * 10) % verd.length]; } else if (strat[0] > 0) { slag = strat[Math.floor(Math.random() * 10) % strat.length]; } else { slag = leeg[Math.floor(Math.random() * 10) % leeg.length]; } if (beurt == 0 && slag > 0) {document.forms[0].elements[slag].click()}; } function win() { if ( cel[1] + cel[2] + cel[3] == 3 || cel[4] + cel[5] + cel[6] == 3 || cel[7] + cel[8] + cel[9] == 3 || cel[1] + cel[4] + cel[7] == 3 || cel[2] + cel[5] + cel[8] == 3 || cel[3] + cel[6] + cel[9] == 3 || cel[1] + cel[5] + cel[9] == 3 || cel[3] + cel[5] + cel[7] == 3 ) { if (confirm("Player 1: You win !!!\nDo you want to play again?")) { wint = 1; xtal++; wie = 'Player 1'; timerID = setTimeout('initieer()',800) } else { xtal++; wie = 'Start'; timerID = setTimeout('initieer()',800) }; } if ( cel[1] + cel[2] + cel[3] == 30 || cel[4] + cel[5] + cel[6] == 30 || cel[7] + cel[8] + cel[9] == 30 || cel[1] + cel[4] + cel[7] == 30 || cel[2] + cel[5] + cel[8] == 30 || cel[3] + cel[6] + cel[9] == 30 || cel[1] + cel[5] + cel[9] == 30 || cel[3] + cel[5] + cel[7] == 30 ) { if (confirm(((auto == 1) ? ('Computer wins, sorry') : ('Player 2: You win !!')) + "!\nDo you want to play again?")) { ytal++; wie = 'Player 1'; timerID = setTimeout('initieer()',800) } else { ytal++; wie = 'Start'; timerID = setTimeout('initieer()',800) }; } } function wisselen(beurt){ if (wissel == 1) { if (beurt == 0) { beurt = 1; wie = "Player " + 1 } else { if (auto == 0) {beurt = 0; wie = "Player " + 2} else {beurt = 0; wie = "Computer";} } if (keren == 9 ) { if (confirm("Tie!!!\n\nDo you want to play again?")) { ztal++; wie = 'Player 1'; timerID = setTimeout('initieer()',800)} else {ztal++; wie = 'Start'; timerID = setTimeout('initieer()',800)}; } } else { beurt = beurt; } wissel = 1; return(beurt); } function wijziging(klik) { plek = cel[klik]; geklikt = klik; if (plek == 0){ if (beurt == 0){ xo = "O"; plek = 10; } else { xo = "X"; plek = 1; } cel[klik] = plek; keren++; } else { if (plek == 10){ xo = "O";} if (plek == 1){ xo = "X";} wissel = 0 } return(xo); } function verdedig() {leeg = new Array(); verd = new Array(); for (i = 1; i < 10; i++) { oud = cel[i]; cel[i] = 1; if ( (cel[1] + cel[2] + cel[3] == 3 || cel[4] + cel[5] + cel[6] == 3 || cel[7] + cel[8] + cel[9] == 3 || cel[1] + cel[4] + cel[7] == 3 || cel[2] + cel[5] + cel[8] == 3 || cel[3] + cel[6] + cel[9] == 3 || cel[1] + cel[5] + cel[9] == 3 || cel[3] + cel[5] + cel[7] == 3) && oud == 0 ) { verd[verd.length] = i} cel[i] = oud; if (cel[i] == 0) { if (keren != 1) {leeg[leeg.length] = i} else if (cel[5] == 0) {leeg[0] = 5; leeg[1] = 10 - geklikt} else if (i % 2 != 0) {leeg[leeg.length] = i} }; } } function aanval() {aanv = new Array(); for (i = 1; i < 10; i++) { oud = cel[i]; cel[i] = 10; if ( (cel[1] + cel[2] + cel[3] == 30 || cel[4] + cel[5] + cel[6] == 30 || cel[7] + cel[8] + cel[9] == 30 || cel[1] + cel[4] + cel[7] == 30 || cel[2] + cel[5] + cel[8] == 30 || cel[3] + cel[6] + cel[9] == 30 || cel[1] + cel[5] + cel[9] == 30 || cel[3] + cel[5] + cel[7] == 30) && oud == 0 ) { aanv[aanv.length] = i} cel[i] = oud; } } function strategie() {strat = new Array(); for (i = 1; i < 10; i++) { oud = cel[i]; cel[i] = 10; if ( (cel[1] + cel[2] + cel[3] == 20 || cel[4] + cel[5] + cel[6] == 20 || cel[7] + cel[8] + cel[9] == 20 || cel[1] + cel[4] + cel[7] == 20 || cel[2] + cel[5] + cel[8] == 20 || cel[3] + cel[6] + cel[9] == 20 || cel[1] + cel[5] + cel[9] == 20 || cel[3] + cel[5] + cel[7] == 20) && oud == 0 ) { if (keren != 3) {strat[strat.length] = i} else if (i % 2 != 0) {strat[strat.length] = i} } cel[i] = oud; } } function wijzig(form,element){ wijziging(element.name); element.value = xo; beurt = wisselen(beurt); form.beurten.value = wie; verdedig(); aanval(); strategie(); win(); if (auto == 0 || wint == 1) {return} else { timerID = setTimeout('zetten()',600) } } initieer(); hi I am trying to create a textarea. There is a default text inside textarea. so when user clicks inside textarea then submit button appears and default text disappears and when user clicks somewhere else or outside textarea then it gets back to original state i.e, default text appears back and submit button disappears. here is what i did sofar. in this code when i click inside textarea then submit button does appear but text does not erase and when i click outside then button remains in sight. 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>Untitled Document</title> <style> #submit { visibility: hidden; } </style> </head> <body> <form> <label>Message:</label> <textarea name="message" id="message" rows="5" cols="30">write message here!</textarea><br /> <input type="button" name="submit" id="submit" value="submit" /> </form> </body> <script type="text/javascript" src="lib/jquery-1.4.min(Production).js"></script> <script> var flag = false; $(document).ready(function () { $('#message').click(function () { flag = true; $('#submit').css('visibility','visible'); if(flag == true) { //alert(flag); var msg = $('#message').val(); //alert(msg); msg = ""; //alert(msg); } }); }); </script> </html> Hello, The following web page is an essay, but there is JavaScript code in the head area: http://www.pinyinology.com/content/content3c.html You can see the 'Press F5 to reset' command, and please try it to see what happens. What I like is to create another command 'Click here to reset'. Therefore, there will be two commands for the reset task. Then it becomes: Click here or press F5 to reset. The press F5 stuff in the code is as follows; Code: //Typewriting code message='<span id="inTxt">wen<sup>2</sup></span>'; pos=0; maxlength=message.length+1; function writemsg() { if (pos<maxlength) { txt=message.substring(pos,0); document.getElementById('edit').innerHTML=txt; pos++; timer=setTimeout('writemsg()', 20); } } //Typewriting code2 own addition message2='<span id="inTxt2">wen<sup>2</sup>闻. ven<sup>2</sup>:文纹. win<sup>2</sup>:蚊. vin<sup>2</sup>:雯.'; pos=0; maxlength=message2.length+1; function writemsg2() { if (pos<maxlength) { txt=message2.substring(pos,0); document.getElementById('listing').innerHTML=txt; pos++; timer=setTimeout('writemsg2()', 20); } } Below is the complete code. It may help. Code: function KeyDown() { var key=window.event.keyCode; if (key==8) { window.event.returnValue=false; var r=document.selection.createRange(); r.collapse(false); r.move("character",-1); r.collapse(false); var p=r.parentElement(); if (p.nodeName.toLowerCase()=="sup"){ p.outerHTML=""; return; } window.event.returnValue=true; } } function KeyPress() { var key=window.event.keyCode; window.event.returnValue=false; if (key>=48 && key<=57) { var r=document.selection.createRange(); r.collapse(false); var d=r.duplicate(); d.moveStart("character",-1); var c=d.text; var p=d.parentElement(); var b=/[A-Za-z]/.test(c); //b=b || p.nodeName.toLowerCase()=="sup"; if (b) { d.collapse(false); var s=String.fromCharCode(key); s=(p.nodeName.toLowerCase()=="sup")? s:"<SUP>"+s+"</SUP>"; d.pasteHTML(s); d.collapse(false); d.select(); return; } } if (!(key in {37:1,38:1,39:1,40:1})) { var r=document.selection.createRange(); r.collapse(false); p=r.parentElement(); if (p.nodeName.toLowerCase()=="sup") { var s=p.outerHTML; p.removeNode(true); r.pasteHTML(s); r.collapse(false); r.select(); } } window.event.returnValue=true; } //Below for status line myMsg = " Happy Chinese typing !" var i = 0; function scrollMsg() { window.status = myMsg.substring(i,myMsg.length) + myMsg.substring(0,i); if (i < myMsg.length) { i++ } else { i = 0 } setTimeout("scrollMsg()",120) } function stoptimer() { clearTimeout(timer); } //Following function is for the appreciation window function newWindow() { catWindow = window.open('appr2.html', 'catwin','width=395,height=235, scrollbars=yes'); catWindow.focus(); } //Typewriting code message='<span id="inTxt">wen<sup>2</sup></span>'; pos=0; maxlength=message.length+1; function writemsg() { if (pos<maxlength) { txt=message.substring(pos,0); document.getElementById('edit').innerHTML=txt; pos++; timer=setTimeout('writemsg()', 20); } } //Typewriting code2 own addition message2='<span id="inTxt2">wen<sup>2</sup>闻. ven<sup>2</sup>:文纹. win<sup>2</sup>:蚊. vin<sup>2</sup>:雯.'; pos=0; maxlength=message2.length+1; function writemsg2() { if (pos<maxlength) { txt=message2.substring(pos,0); document.getElementById('listing').innerHTML=txt; pos++; timer=setTimeout('writemsg2()', 20); } } function stoptimer() { clearTimeout(timer); } Thanks in advance for your help. If anyone is planning on buying "ICAB4225B Automate Processes" in relation to a TAFE/College/School course, I suggest getting the teacher to actually READ the book before they use it. Tonight has been a HE-Double Hockeysticks (Not sure on language in this forum) of fixing mistakes the book has made. Double commars inplace of singles, singles inplace of doubles, single brackets, whole chunks of text that are wrong. In one place in the book it tells me to copy the text in blod and there is none. Anyway.... The code that the book has made me piece together over the last few questions has left me with: Code: <script type = "text/javascript"> { var counter = 0 var NoOfItems var ItemsNames = new Array() NoOfItems = prompt ("How many items do you want to hock?",""); for (NameCount=0; NameCount<NoOfItems; NameCount++) { ItemNames [NameCount] = prompt ("What are the names of your items?",""); } document.write ("<form name='myform'><br><table>"); while ( counter < NoOfItems) { document.write ("<tr><td><value>Enter the price of the " + ItemNames [count] + "</td><td><input type='text' name='" + ItemNames [count] + "'></td></tr>"); counter++ } document.write ("<tr><td><input type='submit' value='Submit Details' onClick='validateform'</td></tr></table></form>"); } </SCRIPT> The problem I am having it with the Array. I dont think that var = new Array is correct but thats what my text book is telling me. Any help? hi i am new to javascript. i make a mcq quiz website in one of server side script. now for that website i want to make count down timer so when that quiz starts the user will have 5 minutes to complete that quiz if use does not able to complete quiz in given time then quiz should disable and shows the user score how can i achieve this |