JavaScript - Newbie - Clarfication Needed
Folks
I am a newbie to JavaScript. I am basically java/j2ee developer . I want to learn javascript and Ajax . So please let me know what is the latest version of JavaScript , also let me know what book I have to buy ( I mean for the newbie ) Please help me . Thanks in Advance Similar TutorialsI have the following code to load iframes but I don't know how to make it load the "LT-video_default.html" when it first loads the page. If I choose one of the options and then go back and choose the "Choose a manufacturer" option it loads the desired page. Here is the code. Code: <script language="JavaScript"> <!-- Begin function leapto(form) { var myindex=form.dest.selectedIndex parent.CONTENT.location.href=(form.dest.options[myindex].value); // You can output to ANY frame using: parent.[framename].location.href } // End --> </script> <div id="videoWrapper"> <form name="labtv"> <select name="dest" size="1" onchange="leapto(this.form)"> <option selected="selected" value="LT-video_default.html">Choose A Manufacturer </option><option value="LT-video_nanodrop.html">NanoDrop </option><option value="LT-video_bioflux.html">Bioflux </option><option value="LT-video_genvault.html">GenVault </option><option value="LT-video_hamilton.html">Hamilton </option></select> </form> <iframe name="CONTENT" frameborder="no" height="400" scrolling="no" width="650"> </iframe> </div> Hey Coding Forum, Hey as you probably know iam new here as i probably haven't even posted this in the correct place but i have a real problem with my JavaScript and i can't get it to do what i would like. I have to write a code to show a new array to represent the third row of a table (var myarray value of which are "60","80","187","180","114" , and creating an array of the required length. Which i have done. (i Think ) I now need to write the remainder of the JavaScript needed to calculate the average height of the objects and write it out in the browser window. It need to write average height 17.2 cm. I have included my script below and but i am not understanding how to work out the average, i believe i need to add another 'for loop' but i can't get it to work correctly. (i might be being completely stupid) If anyone would be able to help it would be GREATLY appreciated. Thanks for all help. <HTML> <HEAD> <TITLE> Test Experiment </TITLE> <SCRIPT LANGUAGE = "JavaScript"> var height = [15,16,17,18,19]; var number = [4,5,11,10,6]; var myarray = new Array(5) var myarray = ["60","80","187","180","114"] ; var values = [60, 80, 187, 180, 114]; var total = 0; for ( var i = 0; i < values.length; ++i ) { total += values[i]; } var myarray = total + values.length; document.write('average height of the object is ' +myarray + '<br>'); </SCRIPT> </HEAD> <BODY> </BODY> </HTML> I'm trying to render 14 same sized images on a webpage using a Javascript, I've used in the past, but now can't seem to get it to work. Getting a Syntax Error. On Page http://www.newenglandonline.net/index.fix.html The ERROR appears to be on the following; line 270: var imageDir = ; [CODE] <script type="text/javascript"> (function() { var rotator = document.getElementById(rotator); var imageDir = ; var delayInSeconds = 3; var images = [Cannon_top.jpg,Mount-Washington-Summer.jpg,Mount-Washington-Winter.jpg,Boston_Charles.jpg,Boston_Harbor.jpg,Boston_Harbor_night.jpg,Zakim Bridge.jpg,Edgartown.jpg,GayHeadLighthouse.jpg,HighlandLight.jpg,Newport.jpg,Bridgeport.jpg,Eastpoin tLight.jpg]; var num = 0; var changeImage = function() { var len = images.length; rotator.src = imageDir + images[num++]; if (num == len) { num = 0; } }; setInterval(changeImage, delayInSeconds * 1000); })(); </script> [CODE] Any help or insight will be greatly appreciated. Thanks in advance. Not new to programming but I am to JQuery (and j/script in general). I need to query a mysql database to return a small amount of data (some text) based on a user code (e.g. MrABC). I could use an iFrame and PHP but if the internet connection is down I do not want error messages displayed - the intended audience have limited cognitive capabilities and will not cope with ERROR 404 etc... Essentially I need to be able to create a function that can be called with a parameter of the usercode and which returns the text from the lookup. What I put in the function is a complete mystery to me ... hi i am trying to populate a textarea with the selections like checkboxes radiobuttons textbox combobox but i cant seem to do so. i am naive to the field of programing, and found a few code snippets to do so i tried but it did no good... help needed this is my code " <html> <head> <style type="text/css"> .minitext { font: normal 0.7em Arial, sans-serif; color: Black; } .disable { background-color: #CF110C; color: #fff; font-weight: bold; padding: 5px; } </style> <script language="Javascript" type="text/javascript"> function populateTextArea(){ var output = new Array(); var fieldID = 1; while (fieldObj = document.MyForm['iid'+fieldID]) { if (fieldObj.length) { for (var j=0; j<fieldObj.length; j++) { if (fieldObj[j].checked) { output[output.length] = fieldObj[j].value;} }//end of for } //end of if else { if (fieldObj.checked) { output[output.length] = fieldObj.value; } }//end of else fieldID++; }// end of while document.getElementById('targetarea').value = output.join(', '); //document.MyForm.targetarea.value = document.MyForm.ip1.value + '\n' + document.MyForm.ip2.value + '\n' + document.MyForm.ip3.value ; } </script> </head> <body> <br> <br> <form name="MyForm" method="POST" action="#"> String 1: <input type="text" name="ip1" value=""><br> String 2: <input type="text" name="ip2" value=""><br> String 3: <input type="text" name="ip3" value=""><br><br> <input type="checkbox" name="iid1" id="pe_item2" value="Text string 1"> Text string <input type="checkbox" name="iid1" id="pe_item2" value="Text string 12"> Text string 1<br><br><br> <input type="radio" name="iid2" id="pe_item4" value="Text string 2">Text string 2 <input type="radio" name="iid2" id="pe_item6" value="Text string 3">Text string 3<br> <input type="radio" name="iid3" id="pe_item8" value="Text string 4">Text string 4 <input type="radio" name="iid3" id="pe_item10" value="Text string 5">Text string 5<br> <input type="radio" name="iid4" id="pe_item12" value="Text string 6">Text string 6 <input type="radio" name="iid4" id="pe_item14" value="Text string 7">Text string 7<br> <br> <br> <a href="#" onClick="document.MyForm.targetarea.value = document.MyForm.ip1.value + '\n' + document.MyForm.ip2.value + '\n' + document.MyForm.ip3.value + populateTextArea();" >Populate</a><br> <br> <INPUT TYPE=BUTTON VALUE="Co" ONCLICK= populateTextArea(); > <br> <textarea id="targetarea" name ="targetarea" cols="50" rows="5"></textarea> </form> </body> </html> " help need this done urgently I created a new website for documentation on the product we sell. It can be found at www.predatorgames.info. On the main page is this nice looking jquery photobox. When you click on the smaller pictures it will reload the main one. My problem is how do I make it so that when you click on the large image it will link to another site. Moreover, when they click on the small image it will load a new large image and I would want that to go to a different site if clicked. Dynamic. I was hoping someone could look at the source and tell me where I need to make the change. Please be specific as this is new to me. Thanks ahead of time for the help! Hello I am new and need some help if possible please. I have a site of which i am putting together for a bit of fun and to teach myself but i need a little help from the masters of script if i may. I have a line of text but need it hidden but whatever i do i cant get it to work. It is on my contact page with HTML & a recaptcha & also a php file. What you see on my site is the following. name then empty field box email address then empty field box subject then field box prefilled with WEB SITE ENQUIRY comments then empty field box. What i would like is for the complete line in BOLD above to be hidden so it cant be seen on the website BUT i can see it when the email is received by me. I am having a bad day by not being able to complete this small task. Any help would be nice if somebody could edit the script for me. Many thanks </script> <div class="email"> <table> </tr> <tr> <td align="justify"> <p align="justify"><label for="name"><b>Name</b> *</label> </td> <td valign="top" align="justify"> <p align="justify"> <input type="text" name="name" maxlength="50" size="40"> </td> <tr> <td valign="top" align="justify"> <p align="justify"><label for="email"><b>Email Address</b> *</label> </td> <td valign="top" align="justify"> <p align="justify"> <input type="text" name="email" maxlength="100" size="40"> </td> <tr> <td valign="top" align="justify"> <p align="justify"><label for="subject"><b>Subject</b> *</label> </td> <td valign="top" align="justify"> <p align="justify"> <input type="text" name="subject" value="WEB SITE ENQUIRY" maxlength="50" size="40"> </td> </tr> <tr> <td valign="top" align="justify"> <p align="justify"><label for="comments"><b>Comments</b> *</label> </td> <td valign="top" align="justify"> <p align="justify"> <textarea name="comments" maxlength="2000" cols="40" rows="6"></textarea> </td> </tr> </table><input class="reset" type="reset" value="Reset All"> Hi guys, i am trying to work with google maps api my issue is with creating an array of markers count the number of marker, and then if it equal two, issue an error msg. i wrote some code, but that doesn't work obviously. and my question is how do i write that code in javascript ? GEvent.addListener(map, 'click', function (overlay, latlng) { if (placeMarker.length < 2) { pendingLatLng = latlng; setTimeout("settleClick()", 225) } else { message("You can only select 2 points."); } }); a sample click event which looks like the line below does work. what am i doing wrong ?: google.maps.event.addListener(map, 'click', function (event) {placeMarker(event.latLng); }) Hi, I am trying to learn how to use radio buttons in javascript without using functions. This is what I did but it does not work: <script language="javascript"> var season3pointer = "Ray Allen" if (season3pointer == Ray Allen) { alert("Good Answer"); } else { alert("You don't know anything about the Celtics") } document.write("<form action='http://www.nba.com/celtics/' method='post'>"+"<p>"+"Who has the record for most 3 points made in a game?"+ "<br/>"+"<input type='radio' name='game-3-pointer' value='bestrecord'>"+season3pointer+ "Antoine Walker"+"<br />"); </script> I know it should be very easy, but so far I have only found how to do it using functions, any help truly appreciated. I am trying to create a personal webpage within Frames. The problem is, when I start the left frame, the main frame does what it's supposed to do, but if I click into the mainframe, it opens in an entirely new window, therefore losing my Frameset. I want to be able to visit webpages I have in an Array and be able to use the webpages (surf them, click on links and such). Please forgive the sloppy coding, I am a beginner. This is what I have so far: Frameset: Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> </head> <frameset cols="220,*" border=5> <frame src="leftFrame.html" name="side" sideborder=1 Scrolling="no" marginwidth="5" marginheight="5" noresize> <frame src="mainFrame.html" name="main" sideborder=1 Scrolling="yes" marginwidth="5" marginheight="5" noresize> </frameset><noframes></noframes> </frameset> <body> </body> </html> Left Frame: Code: <html> <HEAD> <SCRIPT LANGUAGE="JavaScript"> <!-- Begin var page = new Array( "http://google.com" "http://ebay.com" "http://facebook.com" ); var endpage = "/the-end.html"; var slidenum = 0; var slidecount = page.length; var timerID = 0; var show_is_on = 0; var timedelay; var iteration; function showSlideShow() { slidenum++; if (slidenum < slidecount+1) { parent.main.location.href = page[slidenum-1]; document.getElementById('slnum').innerHTML = slidenum } if (slidenum == slidecount+1) { parent.main.location.href = endpage; } else timerID = setTimeout('showSlideShow()', timedelay); } function doShow() { if (!show_is_on) { show_is_on = 1; iteration = document.getElementById('startfrom').value if (iteration > 0) { slidenum = iteration-1 } setTimer(document.getElementById('interval').value); showSlideShow(); } } function stopShow() { clearTimeout(timerID); show_is_on = 0; } function setTimer(milliseconds) { timedelay = milliseconds; } // End --> </script> </HEAD> <P> <form name="form1"> Time delay: <input type="text" size="4" name="interval" id="interval" value="7000" /> <br>(In milliseconds) <P><input type="button" value="Start process" onClick="doShow()" /> <P><input type="button" value="Pause process" onClick="stopShow()" /> <P>Jump to:<input type="text" size="4" name="startfrom" id="startfrom" value="0" /> <P>Progress: <b id="slnum">0</b> of <b id="slcount">0</b> </form> <SCRIPT LANGUAGE="JavaScript"> document.getElementById('slcount').innerHTML = slidecount </SCRIPT> </HEAD> <BODY> </BODY> </html> Main Frame: 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=iso-8859-1" /> <title>Untitled Document</title> </head> <body> </body> </html> Thanks in advance! Hi - can you please tell me the correct syntax for this please? Both scripts 'CalculateBasic' and 'CalculateTape' both happily return the correct amount - all I want to do is add them up to give me a form.price.value I just can't seem to get the right syntax. <script type="text/javascript"> function CalculateTot(form) { form.price.value = CalculateBasic(form) + CalculateTape(form); } </script> Please can you help Thanx I have a js file to clean up a textarea when someone copies from a MS Word. I would like to be able to have this remove all the MS Word on submit rather than select a button in an editor. The cleanup.js in located in an includes folder and here is the submit form. How do I include the cleanup.js in this. Any help would be greatly appreciated! Code: <script language='javascript'> function saveChanges(saveDel) { //set the value based on save,delete, or edit document.editDelete.saveDel.value=saveDel; var retVal=true; document.editDelete.saveDel.onsubmit(); document.editDelete.saveDel.value=saveDel; if(saveDel=='delete') { //bring up a confirm if the user clicks delete retVal=confirm("Permanently delete the current record?"); } if(retVal) { //we can active the submit of the form document.editDelete.saveDel.onsubmit(); document.editDelete.submit(); } } </script> Hi, I am brand new to any sort of programming and am taking an HTML class this quarter. We just started javascript and I am working on an assignment where we make a number guessing game. I have been working on this code for a few days and simply cannot figure out what is wrong. It simply doesn't work and at times locks up my browser (Mozilla Firefox). I don't want anyone to write the code for me, I just need a push to begin to understand what I'm doing wrong. Here is what I have so far: <code> <script type="text/javascript"> function guessingGame(){ var secretNumber=Math.floor(Math.random()*100)+1; var numberOfGuesses=0; var guessNumber=parse.Int(document.getElementById('guessNumberValue').value); document.getElementById("guessNumber").value=guessNumber; while (guessNumber!=secretNumber) { if (guessNumber<secretNumber) document.EricaGuess.response.value="Number too low"; if (guessNumber>secretNumber) document.EricaGuess.response.value="Number too high"; if (guessNumber==secretNumber) document.EricaGuess.response.value="You guessed the correct number!";} numberOfGuesses++; document.EricaGuess.numberOfGuessesValue.value=numberOfGuesses; } </script> </head> <body> <form name="EricaGuess"> <div id="Welcome"> <h2> Welcome to Ericas Guessing Game</h2> <p> Enter a number between 1 and 100. See how quickly you can figure out the magic number</p> <input type="button" value="Guess" onclick="guessingGame()"/> <input type="button" value="Reset" onclick="reset"/> <input type="text" id="guessNumber" name="guessNumberValue"/> <input type="text" id="response" name="response" size="75"/> <input type="text" id="numberOfGuessesValue" name="numberOfGuessesValue"/> </code> This is minus the opening and closing tags. Like I said, I am not asking for anyone to code this for me, just some help to understand what the problems are (I'm sure there are many). Thanks for any help you can give. Hi guys. Noob at Javascrip and html and this is semi-impossible to me currently. I am working on an assignment where I have 10 image files of 10 different countries. the instruction is to create a page that contains a table with 2 columns in a single row. In the first column, create a list of radio buttons that contains the names of the 10 countries. In the second column, display the flag of the country selected in an ?anchor? element. I am required to use the "onclick" event handler. I have been battling with this for hours, as this book I'm learning from makes assumptions as to the syntax I understand, without explaining it... Would someone please be as kind as to set me on the right path. I have included the sorry piece of code I came up with, that I gathered from other sites and tutorials. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Flags</title> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1"/> </head> <body> <script type="text/javascript"> var cuba = "cuba.jpg"; var argentina="argentina.jpg"; </script> <form name="flagList" action="" method="get"> <p>Click on the country name to view its flag.</p> <p> <input type="radio" name="flag" onclick=document.flagList.flagJpg.value=cuba"/> Cuba<br/> <input type="radio" name="flag" onclick=document.flagList.flagJpg.value=argentina"/> Argentina<br/> </p> <p> <textarea name="flagJpg" cols="75" rows="20" style="background-color: blue; border: none; overflow :hidden; font: 10px tohoma; color:#3F3F3F:></textarea> </P> </form> </body> Hi everyone! I want to delete all nodes, but leave one div in my html. var p = document.getElementById('container'); var leave= document.getElementById('leave_this'); while (p.hasChildNodes()) { if(leave != p.childNodes){ p.removeChild(p.firstChild); } } Please help. Cheers Hi what i'm trying to do is have it when once a user clicks on a banner the join raffle button will show after clicking on the banner, along with opening up a new window to the link the banner had. I've been trying to set up a onclick event to do this but haven't had success any help would be appreciated. This is the code ive tried using. <div class="moduletable"> <a onclick="{AUP::RAFFLE=4}" href="http://godaddy.com" target="_blank" mce_href="http://godaddy.com"><img src="/images/stories/godaddy%20image.jpg" alt=""></a> </div> Here is the code for the raffle <tr> <td valign="top" colspan="2"> <form action="" method="post" name="RaffleForm"> <input type="hidden" name="aupraffleid" id="aupraffleid" value="4" /> <input type="hidden" name="aupraffleuserid" id="aupraffleuserid" value="63" /> <input type="hidden" name="auprafflepoints" id="auprafflepoints" value="1" /> <input type="hidden" name="auprafflepointsremove" id="auprafflepointsremove" value="1" /> <input class="button" type="submit" name="Submit" value="Sign up for this raffle now!" /> </form> </td> </tr> Hello, I'm in the process of getting a better understanding of javascript (instead of just copying and pasting JQuery script onto my site). So I have a(dumb?) question. Can I name a var what ever I want? For example, var car_name("Ford Escape"); Or am I misunderstanding this? THanks. I'm new to wordpress, I've just made a website and I want to make small modification: I want to remove the buttons in red. I thought it was CSS. But I've discovered that JS can't be overwritten by CSS so here I am. In firebug, I can see this: element.style { display: block; } When I change it to "display: none" buttons do disappear but I don't know in which file to find this sentence. A JS file is attached as txt. Can anybody give me a hand? This is the site: http://franciscourrea.com/sitio/ buttons by panchoskywalker, on Flickr Hi guys, Started studying HTML , but having a bit of a problem creating <table>s. My instruction is to :"format the row in the table so that they alternate from white to grey. Within the grey rows format the text to white, Withing the white rows, format the text to black. I created a table for this in a previous exercise which I'll paste in the bottom. If I understand correctly, I need to use the table's <tr> element, but I don't know how it should be formatted. Any suggestions would be greatly appreciated. Here is what I got so far; <form action="" name="newsHeadlines"> <table border="0" width="100%"> <tr valign="top"> <td> <select name="headline" multiple="multiple" style="height: 93px"> <option onclick="document.newsHeadlines.news.value=newsItem1"> Investigation of building standards in quake zone </option> <option onclick="document.newsHeadlines.news.value=newsItem2"> Obama sees signs of economic progress </option> <option onclick="document.newsHeadlines.news.value=newsItem3"> Apple aplication downloads approach 1 Billion </option> <option onclick="document.newsHeadlines.news.value=newsItem4"> Jones, Braves beat winless Nationals 8-5 </option> <option onclick="document.newsHeadlines.news.value=newsItem5"> America's uninsured haven't shown collective power </option> </select> </td> <td> <textarea name="news" cols="50" rows="10" style="background-color : Transparent"></textarea> </td> </tr> </table> <script type="text/javascript"> /* <![CDATA[ */ /8 ]]> */ var newsItem1 = "Example1"; var newsItem2 = "Example2"; var newsItem3 = "Example3"; var newsItem4 = "Example4"; var newsItem5 = "Example5"; </script> </form> Hi Everyone I'm learning Javascript with varying degree's of success but am very much in the early phase. My question/problem is this: [ICODE]<!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> </head> <body> <script language="javascript" type="text/javascript"> var degFahren = new Array(212, "string data", -459.67); var degCent = new Array(); var loopCounter; for(loopcounter =0; loopCounter <= 2; loopCounter++){ if(isNaN(degFahren[loopCounter])){ alert("Data " + degFahren[loopCounter] + " at array index " + loopCounter + " is invalid"); continue; } degcent[loopCounter] = 5/9 * (degFahren[loopCounter] -32); } for (loopCounter =2; loopCounter >=0; loopCounter --){ document.write("Value " + loopCounter + " was " + degFahren[loopCounter] + " degrees Fahrenheit"); document.write(" which is " + degCent[loopCounter] + " degrees centigrade<br />"); } </script> </body> </html> /ICODE] The following code does not return any errors in my browser but I'm confused since I'm sure I should be seeing an alert box telling me that there is invalid data entered bu this doesn't happen, also as far as I can make out I should only be receiving an error for the 2nd loop but there seem to be an error message returned for all 3 loops?? This is all possibly correct but I'm learning from a book and I have no-one to ask these mundane questions to. Any help would be greatly received. Sara |