JavaScript - What's Wrong In This Block Of Code? (beginner)
Hey.
I'm kind stuck here. I can't see what's wrong with this small set of code? Is there anything wrong? I'm trying to follow a tutorial at themeforest.net, but i'm getting both confused and frustrated as it doesn't do anything at all! 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> <script src="jquery-1.4.1.min.js" type="text/javascript"></script> <style type="text/css"> #box { height: 300px; width: 300px; background: #2367AB; } </style> <script type="text/javascript"> $(document).ready(function() { $('a').click(function() { $('box').fadeOut(1000); }); }); </script> </head> <body> <div id="box"></div> <a href="#">Click me!</a> </body> </html> Similar TutorialsHey. I'm working on a simple slideshow made with jQuery, and i need some help now. What i'm trying to do now, is to make it change image every X second. I know how to change image, but i'm kind of stuck trying to find out how to make it "do something" every Xth second... i hope you understand what i mean. Here's an example: (obviously not working..) Code: function slideSwitch() { //change image... } setInterval(slideSwitch, 5000); //make the function slideSwitch execute every 5th second. If anyone could help me out here, i'd really appreciate it! Also, is there any "else if" function in jQuery? Like in for example PHP, you can use "if", "else if" and "else".. like this: Code: if(){ }else if(){ }else { } So is there any function like that? I googled it, and i found out i have to use some kind of plugin for it to work? How do i use it? Thanks in advance, -Nike Code: function CalculatePayment(form) { // Check Amount is not a number if (isNaN(form.CheckAmount.value) || form.CheckAmount.value=="") { alert("Please enter a valid check amount."); form.CheckAmount.select(); form.CheckAmount.focus(); return; } else { form.CheckAmount.value = moneyConvert(form.CheckAmount.value); } var totalMoney = parseFloat(form.CheckAmount.value); var copayDue = parseFloat(form.CopayDue.value); var deductibleDue = parseFloat(form.DeductibleDue.value); var totalDue = parseFloat(form.TotalDue.value); // COPAY if (totalMoney > copayDue) { form.Copay.value = moneyConvert(copayDue); totalMoney = (totalMoney - copayDue); } else { form.Copay.value = moneyConvert(totalMoney); totalMoney = 0; } // DEDUCTIBLE if (totalMoney > deductibleDue) { form.Deductible.value = moneyConvert(deductibleDue); totalMoney = (totalMoney - deductibleDue); } else { form.Deductible.value = moneyConvert(totalMoney); totalMoney = 0; } var copay = parseFloat(form.Copay.value); var deductible = parseFloat(form.Deductible.value); // COPAY ADJUSTMENT if (form.FullPay.checked) form.CopayAdjustment.value = moneyConvert(copayDue - copay); else form.CopayAdjustment.value = "0.00"; // DEDUCTIBLE ADJUSTMENT if (form.FullPay.checked) form.DeductibleAdjustment.value = moneyConvert(deductibleDue - deductible); else form.DeductibleAdjustment.value = "0.00"; // OVERPAY form.Overpay.value = moneyConvert(totalMoney); } function convertMoneyCents(txt) { if (!isNaN(txt.value)) { txt.value = moneyConvert(txt.value); } } function DoCal(szTarget, szFieldLabel) { var szDate = window.showModalDialog("../Calendar.html",szFieldLabel,"dialogHeight:230px;dialogWidth:220px;;center=1;status=0"); if((szDate != "") && (szDate != "undefined")) { szTarget.value = szDate; } } function moneyConvert(strval) { strval = Math.abs(strval) + ""; if (strval.indexOf(".") == -1) { strval = strval + '.00'; } else { strval = strval + "00"; strval = strval.substr(0, strval.indexOf(".") + 3); } return strval; } HTML 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> <title>patientCalc</title> <link href="patientCalc.css" rel="stylesheet" type="text/css" /> <script type="text/javascript" src="patientCalc.js"></script> </head> <body> <form id="frmPayment" action=""> <p> Total Balance: <input type="text" id="TotalDue" value="125.25" /> </p> <p> Total CoPay: <input type="text" id="CopayDue" value="114.54" /> </p> <p> Total Deductible: <input type="text" id="DeductibleDue" value="10.71" /> </p> <p> Original Total: <input type="text" id="OriginalTotal" value="125.25" disabled="disabled" /> </p> <p> Check Amount: <input type="text" id="CheckAmount" /> </p> <p> Copay: <input type="text" id="Copay" /> </p> <p> Deductible: <input type="text" id="Deductible" /> </p> <p> Pay in Full: <input type="checkbox" id="FullPay" checked="checked" /> </p> <p> Copay Adjustment: <input type="text" id="CopayAdjustment" /> </p> <p> Deductible Adjustment: <input type="text" id="DeductibleAdjustment" /> </p> <p> Overpay: <input type="text" id="Overpay" /> </p> <p> <input type="button" value="Calculate Payment" onclick="CalculatePayment(document.forms[0]);" /> </p> </form> </body> </html> the Deductible keeps coming up 0.00 In my table i have search functionality based dropdown values. when i do search "Opportunity" from dropdown, it always goes to "Organization" page. because, in onsubmit the value comes as "ozSlsCustomerQuickFind.jsp" that's why the "action" is always comes as "ozSlsCustomerQuickFind.jsp" instead of search value. Here is the code for the dropdown values and search button. Code: buf.append( "<table cellspacing=0 cellpadding=1 border=0 align=left>" ); buf.append( "<tr><td class=verySmall align=left>" ); buf.append( " <form name=QF id=QF action=\"ozSlsCustomerQuickFind.jsp\" method=post onSubmit=\"Javascript:document.QF.action=document.QF.searchDest.options[document.QF.searchDest.selectedIndex].value;\">" ); buf.append( " <input class=textInputSmall type=text name=quickFindText value=\"\">" ); buf.append( " <select name=\"searchDest\" id=\"searchDest\" class=textInputSmall>" ); buf.append( " <option value=\"ozSlsCustomerQuickFind.jsp\" "+(cat.startsWith("CUSTOMER")?"selected":"")+">"+_p.get("organization") ); buf.append( " <option value=\"ozSlsContactQuickFind.jsp\" "+(cat.startsWith("CONTACT")?"selected":"")+">"+_p.get("contact") ); buf.append( " <option value=\"ozSlsOppQuickFind.jsp\" "+(cat.startsWith("OPP")?"selected":"")+">"+_p.get("opportunity") ); buf.append( " <option value=\"ozCalTaskQuickFind.jsp\" "+(cat.startsWith("TASK")?"selected":"")+">"+_p.get("task") ); buf.append( " </select>" ); buf.append( "<input class=\"smallButton\" type=submit name=go value="+_p.get("search")+">" ); buf.append( "</td><td></form></td></tr>" ); buf.append( "</table>" ); Can anybody give an idea on this ? So this is suppose to scrape a page and take data from it and put it in a text box on my web page. This is the web page that I'm taking the info from, https://147.241.62.30/4dwxPortal/web/191/7, and here is a link to the source code I have pulled up from IE Developer Tools: http://i1228.photobucket.com/albums/...h/scraper2.jpg here is my code: Code: <script type="text/javascript"> function temperature(theTemp){ var config = <config> <var-def name="stats"> <html-to-xml> <http method="get" url="https://147.241.62.30/4dwxPortal/web/191/7"/> </html-tosml> </var-def> </config>; var s = new scraper(config); var html = new XML(s.stats.substring(s.stats.indexof("?>") + 2)); var downloads = html.body.div.div.(div[2]).div.div.div.div.section.div.div.div.form.div.table.tbody.tr.(td[2]).div.table.tbody.tr.td.div.toString(); theTemp.value = downloads; } </script> I get an error in the HTML code saying that it expects an object. here is the code where I call the function: Code: <html> <body> <input id="Button61" type="button" value="Calculate" style=" Width:110px; position:absolute; left:4.65in;" onclick="temperature(document.getElementById('TextBox313'))" /> </body> <html> What am I doing wrong? I watched what the guy did on youtube http://www.youtube.com/watch?v=-E67f0TqsDY to write this, either something is wrong with my javascript or I'm calling the text in the website wrong or both... Hi, I've got an html page that has it's overflow hidden with integrated css, now I want to use javascript to set overflow to hidden as soon as an swf is finished. My code is function hidelayer(lay) { document.getElementByName('body').style.overflow = 'visible'; } and I'm calling this function from flash with: getURL("javascript:hidelayer('newlayer');"); in the last frame. But the overflow stays hidden, so apparantly my javascript is wrong. The overflow is set to hidden in the body tag btw. Can anyone help me? Hi In my form i have delete Image. When i click on that image needs to delete the related record. I wrote this the following logic when i click on the image, it is not invoking the onClick logic. is there any syntax wrong in this logic. Acutally before adding this schId Code: schId='<%=cs.getTmpl().getID()%> the form logic is calling. but after i add schId , it's not calling . Code: <td class=ppolSmallText align="right" width="85%" nowrap><img src="graphics/ozIcon12Del.gif" onClick="document.displaySchedule.elements['ahsFormAction'].value='delSchedule&schId='<%=cs.getTmpl().getID()%>;document.displaySchedule.submit();"></td> Please give me an Idea on this ?? Hello, if you could please tell me what I did wrong to make this code not work. Can you put a variable in a function callback ? Quote: <script type="text/javascript"> var aaa = prompt('number?') var obja = new Const(aaa); functin Const(numb){ this.x=numb; alert(obja.x); } </script> Could someone please tell me why this doesn't work??? <html> <head> <title>slideshow</title> </head> <body> <script type="text/javascript"> theimage = new Array(); // The dimensions of ALL the images should be the same or some of them may look stretched or reduced in Netscape 4. // Format: theimage[...]=[image URL, link URL, name/description] theimage[0]=["http://img844.imageshack.us/img844/981/img3small.jpg", length="380", width="380"]; theimage[1]=["http://img850.imageshack.us/img850/4371/img2small.gif", length="380", width="380"]; theimage[2]=["http://img191.imageshack.us/img191/2923/img1small.gif", length="380", width="380"]; ///// Plugin variables playspeed=3000;// The playspeed determines the delay for the "Play" button in ms dotrans=1; // if value = 1 then there are transitions played in IE transtype='blendTrans';// 'blendTrans' or 'revealtrans' transattributes='23';// duration=seconds,transition=#<24 //##### //key that holds where in the array currently are i=0; //########################################### window.onload=function(){ //preload images into browser preloadSlide(); //set transitions GetTrans(); //set the first slide SetSlide(0); //autoplay PlaySlide(); } //########################################### function SetSlide(num) { //too big i=num%theimage.length; //too small if(i<0)i=theimage.length-1; //switch the image if(document.all&&!window.opera&&dotrans==1)eval('document.images.imgslide.filters.'+transtype+'.Appl y()') document.images.imgslide.src=theimage[i][0]; if(document.all&&!window.opera&&dotrans==1)eval('document.images.imgslide.filters.'+transtype+'.Play ()') } //########################################### function PlaySlide() { if (!window.playing) { PlayingSlide(i+1); if(document.slideshow.play){ document.slideshow.play.value=" Stop "; } } else { playing=clearTimeout(playing); if(document.slideshow.play){ document.slideshow.play.value=" Play "; } } // if you have to change the image for the "playing" slide if(document.images.imgPlay){ setTimeout('document.images.imgPlay.src="'+imgStop+'"',1); imgStop=document.images.imgPlay.src } } //########################################### function PlayingSlide(num) { playing=setTimeout('PlayingSlide(i+1);SetSlide(i+1);', playspeed); } //########################################### //desc: picks the transition to apply to the images function GetTrans() { //si=document.slideshow.trans.selectedIndex; if((document.slideshow.trans && document.slideshow.trans.selectedIndex == 0) || (!document.slideshow.trans && dotrans==0)){ dotrans=0; } else if ((document.slideshow.trans && document.slideshow.trans.selectedIndex == 1) || (!document.slideshow.trans && transtype == 'blendTrans')){ dotrans=1; transtype='blendTrans'; document.imgslide.style.filter = "blendTrans(duration=1,transition=1)"; }else{ dotrans=1; transtype='revealtrans'; if(document.slideshow.trans) transattributes=document.slideshow.trans[document.slideshow.trans.selectedIndex].value; document.imgslide.style.filter = "revealTrans(duration=1,transition=" +transattributes+ ")"; } } //########################################### function preloadSlide() { for(k=0;k<theimage.length;k++) { theimage[k][0]=new Image().src=theimage[k][0]; } } </script> <form name="slideshow"> <table style="width: 502px; height: 358px;" border="1" cellpadding="2" cellspacing="0"> <tbody> <tr> <td align="center"> <a href="#" onmouseover="this.href=theimage[i][1];return false"> <script type="text/javascript"> document.write('<img name="imgslide" id="imgslide" src="'+theimage[0][0]+'" border="0">') </script></a></td> </tr> </tbody> </table> </form> </body> </html> Code: <script type="text/javascript"> function validatePassword() { var strInput //Request user enter their password then check its validity strInput = prompt("Enter your password to check it's validity",""); while (!(strInput.length() >= 7 && strInput.indexOf('*') >=0 0 && (strInput.charAt(0) =+ 'Z')) { alert("Your password is invalid, \n Please try again") strInput = prompt("Enter your password to check it's validity",""); } //Outcome if password is valid alert("Your password is valid") //End while } </script> There is an issue with the while statement that stops it from working, but i fail to see what. need a second pair of eyes OK I am stumped. I am creating a little html to check my js file. I want to have the user enter two parameters and then call the function using those two paramaters and then display the answer on the screen. Here is the html file <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>HomeWork3</title> <script type="text/JavaScript" src="grosspay.js"> </script> </head> <body> <script type="text/javascript"> <![CDATA[ var hoursWorked = parseInt(prompt("Enter the Number of Hours You Worked", "40")); var hourlyRate = parseInt(prompt("Enter the Number of Hours You Worked", "10")); function grossPay(hoursWorked, hourlyRate){ document.writeln(grossPay + " Is your normal amount of your check before taxes are taken out"); } ]]> </script> </body> </html> Here is the JS file function grossPay (hoursWorked, hourlyRate) { if (hoursWorked > 40){ var overTimeHrs = (hoursWorked - 40) var overTimePay = (overTimeHrs * 1.5 * hourlyRate) var regPay = (40 * hourlyRate) var grossPay = regPay + overTimePay return grossPay }else { var grossPay = (40 * hourlyRate) return grossPay} } CAN SOMEONE PLEASE HELP ok i am trying to make a countdown timer from 20 seconds when i click start where am i going wrong with this Code: <html> <head> </head> <body> <script type="text/javascript"> function timer() { var milisec=0 var seconds=20 document.counter.d2.value=20 function display() { if (milisec<=0){ milisec=9 seconds-=1 } if (seconds<=-1){ milisec=0 seconds+=1 } else milisec-=1 document.counter.d2.value=seconds+"."+milisec setTimeout("display()",100) display() }} </script> <form name="counter"> <center> Text Timer<br> <input type="text" size="30" name="d2"> <br> <input type="button" onclick="timer()" value="click me to start"> </center> </form> </body> </html> sorry i think this is in the wrong section...how do i remove I am trying to validate the form on my site using an external js file. Here is the HTML for my form: <form method="post" form action="sendmail.asp"> <p><label for="emailAddr">Email Address: <input id="emailAddr" name="emailAddr" type="text" size="30" class="reqd email" /> </label></p> <p><span id="spryselect1"> <label for="Players">Players: <select id="player" class="reqd" name="player"> <option value="" selected="selected">Choose a Player</option> <option value="Woodson">Charles Woodson</option> <option value="Rodgers">Aaron Rodgers</option> <option value="Driver">Donald Driver</option> <option value="Hawk">A.J. Hawk</option> <option value="Barnett">Nick Barnett</option> <option value="Bigby">Atari Bigby</option> </select> </label> <span class="selectRequiredMsg">Please select an item.</span></span></p> <p><label for"options"> Size(default is X-Large): <label for="medium"><input type="checkbox" name="options" id="medium" value="Medium" /> X-Large</label> <label for="large"><input type="checkbox" name="options" id="large" value="Large" /> Large</label> </p> <p> <label for="setStyle">Jersy Style: <input type="radio" id="homeStyle" name="setStyle" value="homeStyle" class="radio" /> Home <input type="radio" id="awayStyle" name="setStyle" value="awayStyle" class="radio" /> Away </label></p> <p> <label for="zip"> Zip: <input id="zip" name="zip" type="text" size="10" maxlength="5" class="isZip dealerList" /> </label></p> <p><input type="submit" value="Submit" /> <input type="reset" /></p> <p> </p> <p> </p> </form> Here is the JavaScript file attached: window.onload = initForms; function initForms() { for (var i=0; i< document.forms.length; i++) { document.forms[i].onsubmit = function() {return validForm();} } document.getElementById("medium").onclick = sizeSet; } function validForm() { var allGood = true; var allTags = document.getElementsByTagName("*"); for (var i=0; i<allTags.length; i++) { if (!validTag(allTags[i])) { allGood = false; } } return allGood; function validTag(thisTag) { var outClass = ""; var allClasses = thisTag.className.split(" "); for (var j=0; j<allClasses.length; j++) { outClass += validBasedOnClass(allClasses[j]) + " "; } thisTag.className = outClass; if (outClass.indexOf("invalid") > -1) { invalidLabel(thisTag.parentNode); thisTag.focus(); if (thisTag.nodeName == "INPUT") { thisTag.select(); } return false; } return true; function validBasedOnClass(thisClass) { var classBack = ""; switch(thisClass) { case "": case "invalid": break; case "reqd": if (allGood && thisTag.value == "") { classBack = "invalid "; } classBack += thisClass; break; case "radio": if (allGood && !radioPicked(thisTag.name)) { classBack = "invalid "; } classBack += thisClass; break; case "isNum": if (allGood && !isNum(thisTag.value)) { classBack = "invalid "; } classBack += thisClass; break; case "isZip": if (allGood && !isZip(thisTag.value)) { classBack = "invalid "; } classBack += thisClass; break; case "email": if (allGood && !validEmail(thisTag.value)) { classBack = "invalid "; } classBack += thisClass; break; default: if (allGood && !crossCheck(thisTag,thisClass)) { classBack = "invalid "; } classBack += thisClass; } return classBack; } function crossCheck(inTag,otherFieldID) { if (!document.getElementById(otherFieldID)) { return false; } return (inTag.value != "" || document.getElementById(otherFieldID).value != ""); } function radioPicked(radioName) { var radioSet = ""; for (var k=0; k<document.forms.length; k++) { if (!radioSet) { radioSet = document.forms[k][radioName]; } } if (!radioSet) { return false; } for (k=0; k<radioSet.length; k++) { if (radioSet[k].checked) { return true; } } return false; } function isNum(passedVal) { if (passedVal == "") { return false; } for (var k=0; k<passedVal.length; k++) { if (passedVal.charAt(k) < "0") { return false; } if (passedVal.charAt(k) > "9") { return false; } } return true; } function isZip(inZip) { if (inZip == "") { return true; } return (isNum(inZip)); } function validEmail(email) { var invalidChars = " /:,;"; if (email == "") { return false; } for (var k=0; k<invalidChars.length; k++) { var badChar = invalidChars.charAt(k); if (email.indexOf(badChar) > -1) { return false; } } var atPos = email.indexOf("@",1); if (atPos == -1) { return false; } if (email.indexOf("@",atPos+1) != -1) { return false; } var periodPos = email.indexOf(".",atPos); if (periodPos == -1) { return false; } if (periodPos+3 > email.length) { return false; } return true; } function invalidLabel(parentTag) { if (parentTag.nodeName == "LABEL") { parentTag.className += " invalid"; } } } } function sizeSet() { if (this.checked) { document.getElementById("homeStyle").checked = true; } } Thank you very much in advance for any and all help. I am a noob with JavaScript. I didn't know where else to turn for help. Thanks in advance, guys. The URL of the page I'm working on can be found he http://graph-art.matc.edu/romanot/vi...inal/order.php Ok, the code below works ok in Firefox but not in IE and I can't figure out why. Please note that when I include the movie src in the body tag, the way it is in the code below, the movie loads fine but the window does not resize as it should (see the document.getElementByID). When I take the movie src out of the body tag however, it doesn't load. It's supposed to load just from the javascript meaning the src shouldn't need to be in the body for this to work. Can anyone see what the problem is? Code: <html> <head> <style type="text/css"> <!-- .fontStyle { font-family: Verdana, Geneva, sans-serif; font-size: small; font-weight: bold; color: #67A2DC; } --> </style> <script type="text/javascript"> /*window.onload=function(){ loadVideo(); } /* function wait() { //loadVideo(); setTimeOut("loadVideo()", 2000); } */ function loadVideo() { <!-- if (parseInt(navigator.appVersion)>3) { if (navigator.appName == "Netscape") { winW = window.innerWidth; winH = window.innerHeight; } if (navigator.appName.indexOf("Microsoft") != -1) { winW = document.body.offsetWidth; winH = document.body.offsetHeight; } } var dimW = winW-50; var dimH = winH-20; var w1 = dimW.toString(); var h1 = dimH.toString(); if(document.getElementById("vidEmbed") != null) { document.getElementById("vidEmbed").src = "oracleWelcome_1.wmv"; document.getElementById("vidEmbed").style.width = w1; document.getElementById("vidEmbed").style.height = h1; } else if(document.getElementById("Player") != null) { document.getElementById("Player").style.width = w1; document.getElementById("Player").style.height = h1; document.getElementById("objectSrc").value = "oracleWelcome_1.wmv"; } } </script> </head> <body><div> <p><span class="fontStyle">Introduction<br> </span> <object id="Player" width="100%" height="100%" classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" style="border:0px;"> <param name="autoStart" value="True"> <param name="uiMode" value="full"> <param name="volume" value="50"> <param name="mute" value="false"> <param name="URL" id="objectSrc" value=""> <embed src="" id="vidEmbed" width="100%" height="100%" autostart="true" uimode="full" volume="50" mute="false"> </embed> </object> </p><body onload="loadVideo();"></body> </div> </body> </html> i have been working on Javascript and HTML for long time but never had such kind of a problem. A very simple code isnt getting executed. Please help me out with what i am missing : Here is the HTML code with javascript(a very simple webpage to say hello) : Code: <html> <head> <script type = "Javascript"> function say_hi() { window.alert("Said hiii.."); } </script> </head> <body> ahgdahsgdhagshd <input type = "checkbox" onclick= say_hi()/>click the check box sdfsdf </body> </html> Problem is that say_hi() isnt getting called. I have tried : Code: onclick= "say_hi();" also.. but still its not getting called when i am clicking the checkbox which it should!!! Yes but if i am writing : Code: onclick= "window.alert("Hi");" then its getting executed!!!. Whats going on here in my code. Thanks in advance Simply what is wrong with my code. The following code is for a simple slideshow that is supposed to accept a range of images to display. Its for a website where it shows all the store for a company and when you rollover the image of it is plays a slideshow of images. If you have any other way of doing this that would be easier than please post it here. It must work in all browsers. As you can see there are lots of images to me loaded for this Code: <!-- var image1=new Image() image1.src="contact/images/wingham/01.jpg" var image2=new Image() image2.src="contact/images/wingham/02.jpg" var image3=new Image() image3.src="contact/images/wingham/03.jpg" var image4=new Image() image4.src="contact/images/wingham/04.jpg" var image5=new Image() image5.src="contact/images/wingham/05.jpg" var image6=new Image() image6.src="contact/images/wingham/06.jpg" var image7=new Image() image7.src="contact/images/listowel/01.jpg" var image8=new Image() image8.src="contact/images/listowel/02.jpg" var image9=new Image() image9.src="contact/images/listowel/03.jpg" var image10=new Image() image10.src="contact/images/listowel/04.jpg" var image11=new Image() image11.src="contact/images/listowel/05.jpg" var image12=new Image() image12.src="contact/images/listowel/06.jpg" var image13=new Image() images13.src="contact/images/hanover/01.jpg" var image14=new Image() images14.src="contact/images/hanover/02.jpg" var image15=new Image() images15.src="contact/images/hanover/03.jpg" var image16=new Image() images16.src="contact/images/hanover/04.jpg" var image17=new Image() images17.src="contact/images/hanover/05.jpg" //--> <!-- //variable that will increment through the images var step=1 function slideit(start,finish,action){ if(action == 'abort'){ return } //if browser does not support the image object, exit. if (!document.images) return document.images.slide.src=eval("image"+step+".src") if (step<finish){ step++ } else{ step=start } //call function "slideit()" every 2.5 seconds timer = setTimeout("slideit(start,finish)", 1000); } function slideOff() { document.images.slide.src=eval("image1.src") clearTimeout(timer); } //Called something like this: slideit(1,6)// Code: <script> // Calculate and display the total cost of the selected cruise function CostOfCruise(findRounding) { //Get the varius elements in the statements and variable document.getelementbyID ("costCruise" + i); //Assign a value to the radioButton document.getElementById("returnFare"); //Assign a vlaue to the checkbox document.getElementById("costSeat" + i); //Assign a value to the second radio button document.getElementById ("totalCost"); //Assign a value to the total cost of the cruise document.getElementById("findRounding"); //Assign a rounded value to the total cost //List the variables involved var radioButton; // A radio button var costCruise; //Cost of each cruise var checkbox; //A checkbox var returnFare; //The reutrn fare var radio; //the second set of radio buttons var costSeat; //Cost of seating choice var totalCost; //The final cost of the cruise //Determine the cruise chosen and its cost //Get the cost of the selected cruise for (var i = 1; i <= 5; i++) radioButton = document.getElementById("Costcruise" + i); // Display the appropriate response if (radioButton.value === "") alert("You need to choose one of the islands to visit."); else (radioButton.checked === true); //Get the cost of the cruise as a whole number costCruise *= parseInt(radioButton.value); //Determine if return fare purchased // Check if the object is valid before attempting to use it if (returnFare.value === null) return; else (checkbox.checked === true); checkbox = document.getElementById("returnFare"); //Get the value of the reutrn fare as a whole number returnFare *= parseInt(checkbox.value); //Determine which type of seating chosen if (radio.value === "") alert("You need to choose your preferred seating arrangements."); else (radio.checked === true); radio = document.getElementById("costSeat" + i); //Get the cost of the seating as a whole number costSeat *= parseFloat(radio.value); //Calculate total cost of cruise totalCost = document.getElementById ("totalCost"); totalCost = ("costCruise" * "returnFare") * "costSeat"; //Total Cost of cruise //rounds the cost to its nearest integer findRounding = document.getElementById("findRounding"); findRounding = Math.round("totalCost"); alert ("The total cost of this cruise is $" + findRounding); } </script> <html> body> <h1>Island Hopper Cruises Fare Calculator</h1> <p> Complete the form below to calculate the cost of your cruise.</p> <form> <!--The choices of islands to visit with their assigned values or cost of the trip.--> <p>Route:<br /> <input type="radio" id="cruise1" name="costCruise" value="49"> <label for="cruise1">Main Beach - Azkaban Island</label><br> <input type="radio" id="cruise2" name="costCruise" value="79"> <label for="cruise2">Main Beach - Amity Island</label><br> <input type="radio" id="cruise3" name="costCruise" value="109"> <label for="cruise3">Main Beach - Treasure Island</label><br> <input type="radio" id="cruise4" name="costCruise" value="89"> <label for="cruise4">Main Beach - Gilligan's Island</label><br> <input type="radio" id="cruise5" name="costCruise" value="59"> <label for="cruise5">Main Beach - Skull Island</label><br></p> <!--The decision to purcahse a return fare or not.--> <p> Click here if you will be purchasing a return fa <input type="checkbox" id="returnFare" name="returnFare" value="2"></p> <!--The choice of seating arrangment and their assigned value according to class of seat.--> <p>Seating:<br /> <input type="radio" id="first" name="costSeat" value="2.5"> <label for="first">First class</label><br> <input type="radio" id="busi" name="costSeat" value="1.5"> <label for="busi">Business class</label><br> <input type="radio" id="econ" name="costSeat" value="1"> <label for="econ">Economy class</label><br></p> <!--The total cost of the chosen trip displayed as an alert.--> <input type="button" value="Calculate" onclick="CostOfCruise"> <input type="reset" value="Reset"> </form> </body> </html> Could anyone tell me what I've doing wrong, on first click it detects that the div is hidden and makes it visible, button on second click it does nothing: Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <link href="basic.css" rel="stylesheet" type="text/css" /> <script type="text/javascript"> function hideshow(id) { if (document.getElementById(id).style.visibility = "hidden") { document.getElementById(id).style.visibility = "visible"; } else { document.getElementById(id).style.visibility = "hidden"; } } </script> </head> <body> <div id="test" onclick="hideshow('test2')"> </div> <div id="test2" style="visibility:hidden"> </div> </body> </html> Code: <html> <head> <title> Caught </title> <script language="JavaScript"> <-- hide me // get user to add name var name_entry = prompt ("Please Enter your Name!", "James"); // declare some short strings var stating = ", I knew you did it!" var told = "I told you that I would find out" var mistake = "I guess you just made a mistake entering your name," var punish = "Now go back to your room" // construct some longer strings var stating_name = name_entry + stating; var mistake_name = mistake + name_entry; // stop hiding me --> </script></head><body> <h1> OI Stop! </h1> <script language="JavaScript"> <!-- hide me document.writeln(stating_name + "<br>"); document.writeln(told = "<br>"); document.writeln(mistake_name = "<br>"); document.writeln(punish = "<br>"); // show me --> </script> </head> <p> <FORM> <INPUT TYPE="button" VALUE="To Your Room" onClick="history.back()"> </FORM> </p> </body></html> It will not show my strings and variables?? Please Help!! HTML CODE BELOW (JAVASCRIPT CODE FOLLOWS); Code: <!DOCTYPE html> <html> <head> <meta http-equiv="content-type" content="text/html;charset=utf-8"> <title>Text Object value Property</title> <script type="text/javascript" src="../jsb-global.js"></script> <script type="text/javascript" src="jsb-11-02.js"></script> </head> <body> <h1>Text Object value Property</h1> <form id="UCform" action="make-uppercase.php"> <p> <input type="text" id="converter" name="converter" value="sample"> </p> </form> </body> </html> This program below switches what is entered into the text filed to caps when hitting the enter button or the tab button. Can someone explain to me why it is not working. The answer would be helpful to a newbie who's trying hard to learn the fundamentals... Code: // initialize when the page has loaded window.onload = initialize; var oInput; // (global) input field to make uppercase // apply behaviors when document has loaded function initialize() { // do this only if the browser can handle DOM methods if (document.getElementById) { // apply event handler to the button oInput = document.getElementById('converter'); if (oInput){ var event = oInput.onchange; upperMe(event); } // apply event handler to the form var oForm = document.getElementById('UCform'); if (oForm) { var event = oForm.onsubmit; upperMe(event); } } } // make the text UPPERCASE function upperMe(evt) { // consolidate event handling if (!evt) evt = window.event; // set input field value to the uppercase version of itself var sUpperCaseValue = oInput.value.toUpperCase(); oInput.value = sUpperCaseValue; // cancel default behavior (esp. form submission) // W3C DOM method (hide from IE) if (evt.preventDefault) evt.preventDefault(); // IE method return false; } |