JavaScript - What Am I Doing Wrong ?
Hello people, I have just started to dabble in Javascript and for my first 'project' i want to display a popup window in the center of the current browser window.
I am usng the following script and when testing it using firefox/mozilla it works really well, however when i test it using Internet Explorer it goes a little wonky. here is my script: function doBubblePopUp(myId, moduleId){ var myWidth = 0, myHeight = 0; if( typeof( window.innerWidth ) == 'number' ) { //Non-IE myWidth = window.innerWidth; myHeight = window.innerHeight; } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) { //IE 6+ in 'standards compliant mode' myWidth = document.documentElement.clientWidth; myHeight = document.documentElement.clientHeight; } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) { //IE 4 compatible myWidth = document.body.clientWidth; myHeight = document.body.clientHeight; } var centerX = parseInt(myWidth / 2) - 225; var centerY = parseInt(myHeight / 2) - 275; i have looked at lots of tutorial and reference sites and with my limited understanding, the above script should work. any help would be gratefully appreciated, Similar Tutorialshere is my code Code: <input type="button" onclick='fetch(\"no\", \"wifi.pl?action=connect&network="+document.getElementById(\'networkname\').value+"\");' value="Connect"> no matter how i try the combinations of '"\" i cannot seem to get the element value in the onclick. the fetch('no', 'url'); // no means just send the info and not get results just incase anyone was wondering. is just an ajax query I have some inline javascript/jquery that won't function when I move it from inside the body tag. I want to put it into an external file. The proper Jquery library tag is setup and external .js files are linking correctly, Am I missing something in my code? Thanks. The script i'm trying to write consist of asking the user for his name in a form format which is then sent in a cookie. When the user reconnect to the same page, it displays : Hi, "HISNAME", welcome to my site! I don't know what I'm doing wrong, seriously. <!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>Untitled Document</title> <script type="text/javascript"> if ( ! get_cookie ( "username" ) ) { var username = document.write( <form name="name"> <table> <tr> <td valign="top"> Name : </td> <td> <input type="text" name="texte" value=""> </td> <td> <INPUT TYPE="button" NAME="bouton" Value="Click" onClick="testResults(this.form)"> </td> </tr> </table> </form>); if ( username ) { var current_date = new Date; var cookie_year = current_date.getFullYear ( ) + 1; var cookie_month = current_date.getMonth ( ); var cookie_day = current_date.getDate ( ); set_cookie ( "username", username, cookie_year, cookie_month, cookie_day ); } } else { var username = get_cookie ( "username" ); document.write ( "Hi " + username + ", welcome to my website!" ); document.write ( "<br><a href=\"javascript:delete_cookie('username'); document.location.reload ( );\"> Forget about me!</a>" ); } </script> </head> <body> </body> </html> I'm trying add the value of multiple text boxes automatically using javascript i revised the code many many times but i cant find an error or maybe im missing something you can find the source code in the link below http://wilson382.info/code.html or just download the file so you can revise and test code easily http://wilson382.info/build.zip what I want to do will work exactly like this: http://wilson382.info/src.html The working code of this script i got it from http://javascriptsource.com/ so credit goes to them thank in advance to anyone who try to help. edit: it works fine now but its not giving me the correct result the correct result is 1076 check it out: http://wilson382.info/build.html HTML Code: <!DOCTYPE HTML> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <!--META TAGS--> <meta http-equiv="content-type" content="text/html;charset=utf-8" /> <meta name="description" content="The best of the internet all in one place" /> <meta name="keywords" content="Votillity,Homepage,Directory,email,file sharing,financial,games,jobs,language,literature,maps,music,news,politics,pro wrestling,science,shopping,social,networking,sports,travel,tv,movies,videos,calculate,calculator," /> <meta name="author" content="Matthew Chatterton" /> <meta name="google-site-verification" content="iJB8KNduVUeBu7MBY6Jyw7WqxekCCgVgwq_arLQGAZk" /> <meta name="alexaVerifyID" content="vbR_arpXTayIO5B7nHs9BjLOYFE" /> <!--STOP META TAGS--> <!--EXTERNAL FILES--> <link rel="stylesheet" type="text/css" href="css/main.css" /> <link id="altstyle" rel="stylesheet" type="text/css" href="css/main.css" /> <script type="text/javascript" src="main.js"></script> <link rel="shortcut icon" href="http://votillity.com/img/VotillityIcon.ico" /> <link rel="apple-touch-icon" href="http://votillity.com/img/VotillityAppleTouchIcon.png" /> <script type="text/javascript" src="jquery-1.4.2.min.js"></script> <!--STOP EXTERNAL FILES--> <title>Votillity.com</title> <!--CSS INTERNAL--> <!--CSS INTERNAL--> <!--JAVASCRIPT INTERNAL--> <!--JAVASCRIPT INTERNAL--> </head> <body onload="startTime()" style="background:#ffffff;"> <button class="buttontabs" style="position:fixed;top:0;left:0;" onclick="function tabs1()">Tab 1</button> <div> <object id="UUS1" style="width:100%;height:96%;visibility:hidden;" data="http://Votillity.com/Votillity.html"> <embed src="http://Votillity.com/Votillity.html"/> </object> </div> <button class="buttontabs" style="position:fixed;top:0;left:80px;" onclick="function tabs2()">Tab 2</button> <div> <object id="UUS2" style="width:100%;height:96%;visibility:hidden;" data="http://Votillity.com/Votillity.html"> <embed src="http://Votillity.com/Votillity.html"/> </object> </div> <button class="buttontabs" style="position:fixed;top:0;left:160px;" onclick="function tabs3()">Tab 3</button> <div> <object id="UUS3" style="width:100%;height:96%;visibility:hidden;" data="http://Votillity.com/Votillity.html"> <embed src="http://Votillity.com/Votillity.html"/> </object> </div> <button class="buttontabs" style="position:fixed;top:0;left:240px;" onclick="function tabs4()">Tab 4</button> <div> <object id="UUS4" style="width:100%;height:96%;visibility:hidden;" data="http://Votillity.com/Votillity.html"> <embed src="http://Votillity.com/Votillity.html"/> </object> </div> <button class="buttontabs" style="position:fixed;top:0;left:320px;" onclick="function tabs5()">Tab 5</button> <div> <object id="UUS5" style="width:100%;height:96%;visibility:hidden;" data="http://Votillity.com/Votillity.html"> <embed src="http://Votillity.com/Votillity.html"/> </object> </div> <button class="buttontabs" style="position:fixed;top:0;left:400px;" onclick="function tabs6()">Tab 6</button> <div> <object id="UUS6" style="width:100%;height:96%;visibility:hidden;" data="http://Votillity.com/Votillity.html"> <embed src="http://Votillity.com/Votillity.html"/> </object> </div> <button class="buttontabs" style="position:fixed;top:0;left:480px;" onclick="function tabs7()">Tab 7</button> <div> <object id="UUS7" style="width:100%;height:96%;visibility:hidden;" data="http://Votillity.com/Votillity.html"> <embed src="http://Votillity.com/Votillity.html"/> </object> </div> <button class="buttontabs" style="position:fixed;top:0;left:560px;" onclick="function tabs8()">Tab 8</button> <div> <object id="UUS8" style="width:100%;height:96%;visibility:hidden;" data="http://Votillity.com/Votillity.html"> <embed src="http://Votillity.com/Votillity.html"/> </object> </div> <button class="buttontabs" style="position:fixed;top:0;left:640px;" onclick="function tabs9()">Tab 9</button> <div> <object id="UUS9" style="width:100%;height:96%;visibility:hidden;" data="http://Votillity.com/Votillity.html"> <embed src="http://Votillity.com/Votillity.html"/> </object> </div> <p class="counter" style="position: fixed; bottom: -18px; right: 3px;"></p> <span class="time" style="position: fixed; top: 0px; right: 5px; font-weight: 900; color: green;" id="time"></span> </body> </html> Javascript Code: function tabs1() { var tabs1 = [ { document.getElementById('UUS2') }, { document.getElementById('UUS3') }, { document.getElementById('UUS4') }, { document.getElementById('UUS5') }, { document.getElementById('UUS6') }, { document.getElementById('UUS7') }, { document.getElementById('UUS8') }, { document.getElementById('UUS9') } ]; document.tabs1.style.visibility='hidden' document.getElementById('UUS1').style.visibility="visible" } function tabs2() { var tabs2 = [ { document.getElementById('UUS1') }, { document.getElementById('UUS3') }, { document.getElementById('UUS4') }, { document.getElementById('UUS5') }, { document.getElementById('UUS6') }, { document.getElementById('UUS7') }, { document.getElementById('UUS8') }, { document.getElementById('UUS9') } ]; document.tabs2.style.visibility='hidden' document.getElementById('UUS2').style.visibility='visible' } function tabs3() { var tabs3 = [ { document.getElementById('UUS1') }, { document.getElementById('UUS2') }, { document.getElementById('UUS4') }, { document.getElementById('UUS5') }, { document.getElementById('UUS6') }, { document.getElementById('UUS7') }, { document.getElementById('UUS8') }, { document.getElementById('UUS9') } ]; document.tabs3.style.visibility='hidden' document.getElementById('UUS3').style.visibility='visible' } function tabs4() { var tabs4 = [ { document.getElementById('UUS1') }, { document.getElementById('UUS2') }, { document.getElementById('UUS3') }, { document.getElementById('UUS5') }, { document.getElementById('UUS6') }, { document.getElementById('UUS7') }, { document.getElementById('UUS8') }, { document.getElementById('UUS9') } ]; document.tabs4.style.visibility='hidden' document.getElementById('UUS4').style.visibility='visible' } function tabs5() { var tabs5 = [ { document.getElementById('UUS1') }, { document.getElementById('UUS2') }, { document.getElementById('UUS3') }, { document.getElementById('UUS4') }, { document.getElementById('UUS6') }, { document.getElementById('UUS7') }, { document.getElementById('UUS8') }, { document.getElementById('UUS9') } ]; document.tabs5.style.visibility='hidden' document.getElementById('UUS5').style.visibility='visible' } function tabs6() { var tabs6 = [ { document.getElementById('UUS1') }, { document.getElementById('UUS2') }, { document.getElementById('UUS3') }, { document.getElementById('UUS4') }, { document.getElementById('UUS5') }, { document.getElementById('UUS7') }, { document.getElementById('UUS8') }, { document.getElementById('UUS9') } ]; document.tabs6.style.visibility='hidden' document.getElementById('UUS6').style.visibility='visible' } function tabs7() { var tabs7 = [ { document.getElementById('UUS1') }, { document.getElementById('UUS2') }, { document.getElementById('UUS3') }, { document.getElementById('UUS4') }, { document.getElementById('UUS5') }, { document.getElementById('UUS6') }, { document.getElementById('UUS8') }, { document.getElementById('UUS9') } ]; document.tabs7.style.visibility='hidden' document.getElementById('UUS7').style.visibility='visible' } function tabs8() { var tabs8 = [ { document.getElementById('UUS1') }, { document.getElementById('UUS2') }, { document.getElementById('UUS3') }, { document.getElementById('UUS4') }, { document.getElementById('UUS5') }, { document.getElementById('UUS6') }, { document.getElementById('UUS7') }, { document.getElementById('UUS9') } ]; document.tabs8.style.visibility='hidden' document.getElementById('UUS8').style.visibility='visible' } function tabs9() { var tabs9 = [ { document.getElementById('UUS1') }, { document.getElementById('UUS2') }, { document.getElementById('UUS3') }, { document.getElementById('UUS4') }, { document.getElementById('UUS5') }, { document.getElementById('UUS6') }, { document.getElementById('UUS7') }, { document.getElementById('UUS8') } ]; document.tabs9.style.visibility='hidden' document.getElementById('UUS9').style.visibility='visible' } when I click on the buttons, nothing pops up First, I am new to javascript... I've been trying to get help on a dynamic menu but no one ever seems to respond... So I will start with the pieces... I do not understand why this chunk of code is not working... All i have is a div and the script is simply supposed to make the div have a new size... here is the script... Code: <script type="text/javascript"> var stretch = 200; function Expand(index) { var dname = "menu" + index; document.getElementById(dname).style.width = stretch+'px'; } </script> here is the styling Code: <style type="text/css"> .show{height:20px; width:100px; display:block; background:lightgreen;} </style> and here is the simple html Code: <div id="menu1" class="show" onclick="runExpand(1)"></div> first- i wanted to say (for all those who see it before the Mods remove it) how stupid does a bot have to be to set its spam to be resolved at OP? lol so now my question... I have two divs with some styling. Code: #show{CSS code} #menuDet1{CSS code and visibility:hidden;} I then had in html Code: <div id="show" onmouseover="changevis(1)"></div> <div id="me1"></div> and then a function Code: function changevis(index){ acMenuDet="me" + index; document.getElementById(acMenuDet).visibility="visible"; } a colleague of mine helped me "debug" this until it worked and we came up with Code: function details_visible(index) { var acMenuDet = "menuDet" + index; document.getElementById(acMenuDet).style.visibility = "visible"; ; } function details_hidden(index) { var acMenuDet = "menuDet" + index; document.getElementById(acMenuDet).style.visibility = "hidden"; ; } Note: also changed code in div to Code: <div id="show" onmouseover="details_visible(1)" onmouseout="details_hidden(1)"> Hover over me</div> <div id="menuDet1" style="visibility: hidden;" >Plesam Plesam Plesam Plesam Plesam</div> I do not see off the bat what I was doing wrong- anyone else see what I did incorrectly? document.write('<a href='+'"'+imagelinks[ry]+'"'+' target="_blank"><img src="'+myimages[ry]+'" border=0 max-height="250" max-width="900"></a>') I've looked over this 100 times and can't figure it out. The image shows up and you can click it. The max height and width isn't working and the image isn't opening in a new tab. Any help? I realy need help what is wrong with the IF Code: <script type="text/javascript"> function Player(name, xStart, yStart){ this.x = xStart; this.y = yStart; this.name = name; this.walk = playerWalk; this.locate = playerLocate; } var urHere = new Player("You",50,50); function playerWalk(dir){ switch(dir){ case "up": this.y++; break; case "down": this.y--; break; case "left": this.x--; break; case "right": this.x++; break; default: alert("I don't understand: " + dir); } this.locate(); } if (this.y == 50){ document.write ("<h3>Blob Wins!</h3>"); } I get the 'Invalid' confirmation but not the 'Valid' one... WHY? It works when I plug in this instead though... if (user.length < 5) 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>Form Validation</title> </head> <body> <script type="text/javascript"> function checkForm() { var user = document.getElementById('user').value; if (user != "turgeon"){ alert("Invalid Username"); return false; } else{ return true; } } function checkUser() { var user = document.getElementById('user').value; var element = document.getElementById('labelUser'); if(user != "turgeon"){ element.innerHTML = "Invalid Username"; element.style.color = "red"; } else{ element.innerHTML = "Valid Username"; element.style.color = "green"; } } </script> <form onsubmit="return checkForm();"> <input type="text" id="user" onblur="checkUser();" /> <label id="labelUser"></label> <input type="submit" value="submit" /> </form> </body> </html> I am trying to implement a javascript on a page and the error that I get is Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /fullsize/image.php on line 131 On line 131 the code is Code: echo"<img id='thepic' onClick="scaleImg('thepic')" onLoad="scaleImg('thepic')" src='$image'>"; I can't get the function getchecked() to show an alert box... Code: <script> function getCheckedValue(radioObj) { if(!radioObj){ return ""; } var radioLength = radioObj.length; if(radioLength == undefined){ if(radioObj.checked){ return radioObj.value; }else{ return ""; } } for(var i = 0; i < radioLength; i++) { if(radioObj[i].checked) { return radioObj[i].value; } } return ""; } } function getchecked(){ var thecode=getCheckedValue(document.forms['radioExampleForm'].elements['code']); if(thecode!==""){ if(thecode=="HTML"){ alert('Checked value is: '+thecode+'.'); //playSound("test1.mp3"); }else if(thecode=="PHP"){ //playSound("test2.mp3"); alert('Checked value is: '+thecode+'.'); }else{ //playSound("test3.mp3"); alert('Checked value is: nothing'); } } } </script> <label for="code1"><input type="radio" value="HTML" name="code" id="code1"> HTML</label> <br><label for="code2"><input type="radio" value="PHP" name="code" id="code2"> PHP</label> <br><label for="code3"><input type="radio" value="MySQL" name="code" id="code3"> MySQL</label> <br><input type="button" onclick="getchecked()" value="Show Checked Value"> thanks! 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 ?? Hi - I am trying to use this code to validate, function test() { var pattern = (/^\d{3}[-]?\d{2}[-]?\d{4}$/g); var pattern1 = (/^d{3}$/g); if(!pattern.test(document.myform.textInput.value)||(!pattern1.test(document.myForm.textInput.value)) ) { alert("Error!"); } } using regular expressions to compare a string from an input with two patterns that could both be valid. Therefore I'm pretty sure I need to use "||" between them both. I can't quite figure out how to get javascript to check for both patterns, only the first seems to be checked as valid. Is it something to do with the way I have my brackets? Can someone point me in right direction, Thanks I am using an external style sheet to set the color of my calculator to gray. However, when I open my javascript in Google Chrome, the calculator is red. I've checked the style sheet code and it's correct. Can anyone tell me why this is happening? I posted both the html and css code below. 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>Calculator</title> <link rel="stylesheet" type="text/css" href="assignment2.css" /> <div align="center"> <script type="text/javascript"> var title = "<strong>Calculator</br> Aughtman, Zackary</strong>" document.write(title.fontsize(5)); </script> </div> </head> <body> </br> </br> <div align="center"> <table align = "center" border="1" bordercolor="div1" bgcolor="div2"> <tr> <td colspan="4"> <input type="text" value="" id="results" class="results" /> </td> </tr> <tr> <td> <input type="button" style="width:30px" value="7" onclick="EnterNumber(this.value)"> </td> <td> <input type="button" style="width:30px" value="8" onclick="EnterNumber(this.value)"> </td> <td> <input type="button" style="width:30px" value="9" onclick="EnterNumber(this.value)"> </td> <td> <input type="button" style="width:30px" value="/" onclick="EnterOperator(this.value)"> </td> </tr> <tr> <td> <input type="button" style="width:30px" value="4" onclick="EnterNumber(this.value)"> </td> <td> <input type="button" style="width:30px" value="5" onclick="EnterNumber(this.value)"> </td> <td> <input type="button" style="width:30px" value="6" onclick="EnterNumber(this.value)"> </td> <td> <input type="button" style="width:30px" value="*" onclick="EnterOperator(this.value)"> </td> </tr> <tr> <td> <input type="button" style="width:30px" value="1" onclick="EnterNumber(this.value)"> </td> <td> <input type="button" style="width:30px" value="2" onclick="EnterNumber(this.value)"> </td> <td> <input type="button" style="width:30px" value="3" onclick="EnterNumber(this.value)"> </td> <td> <input type="button" style="width:30px" value="-" onclick="EnterOperator(this.value)"> </td> </tr> <tr> <td> <input type="button" style="width:30px" value="0" onclick="EnterNumber(this.value)"> </td> <td> <input type="button" style="width:30px" value="N" onclick="EnterNumber(this.value)"> </td> <td> <input type="button" style="width:30px" value="L" onclick="EnterNumber(this.value)"> </td> <td> <input type="button" style="width:30px" value="+" onclick="EnterOperator(this.value)"> </td> </tr> <tr> <td> <input type="button" style="width:30px" value="" onclick="EnterNumber(this.value)"> </td> <td> <input type="button" style="width:30px" value="" onclick="EnterNumber(this.value)"> </td> <td> <input type="button" style="width:30px" value="=" onclick="EnterNumber(this.value)"> </td> <td> <input type="button" style="width:30px" value="C" onclick="EnterOperator(this.value)"> </td> </tr> </table> </br> <script type="text/javascript"> document.write("<strong>Instructions</strong></br>"); document.write("Click a number, then an action, then another number, then the equals button.</br>"); document.write("Press C when ready to start over.</br>"); document.write("The N button makes your previous number a negative.</br>"); document.write("The L button requires one number to be available,</br>"); document.write("it will loop through that numberto ten plus that number</br>"); document.write("and add all values and display.</br>"); document.write("For example: 1+2+3+4+5+6+7+8+9+10=55</br></br>"); document.write("<strong>Navigator Info</strong></br>"); document.write("App Name: Netscape</br>"); document.write("Cookes Enable: true</br>"); document.write("User agent Mozilla 5.0 Windows NT 5.1; rv:6.0 Gecko 20100101 Firefox 6.0</br>"); </script> </div> </body> </html> Code: #div1 {color:#999999} #div2 {color:#999999} I'm trying to get this calculator to work html Code: <form name="Calc" id="calculator" style="position: fixed; top: 25px; right: 5px; background: #5F4A29;" action=""> <table border="6"> <tr> <td colspan="4"><input type="text" name="Input" size="25" onclick="calc(Calc); return true" /></td> </tr> <tr> <td><input class="button" type="button" name="clr" value="c" onclick="calc(Calc)" /></td> <td><input class="button" type="button" name="(" value="(" onclick="calc(Calc)" /></td> <td><input class="button" type="button" name=")" value=")" onclick="calc(Calc)" /></td> <td><input class="button" type="button" name="equ" value="=" onclick="calc(Calc)" /></td> </tr> <tr> <td><input class="button" type="button" name="_1" value="1" onclick="calc(Calc)" /></td> <td><input class="button" type="button" name="_2" value="2" onclick="calc(Calc)" /></td> <td><input class="button" type="button" name="_3" value="3" onclick="calc(Calc)" /></td> <td><input class="button" type="button" name="add" value="+" onclick="calc(Calc)" /></td> </tr> </tr> <tr> <td><input class="button" type="button" name="_4" value="4" onclick="calc(Calc) += '4'" /></td> <td><input class="button" type="button" name="_5" value="5" onclick="calc(Calc) += '5'" /></td> <td><input class="button" type="button" name="_6" value="6" onclick="calc(Calc) += '6'" /></td> <td><input class="button" type="button" name="sub" value="-" onclick="calc(Calc)" /></td> </tr> <tr> <td><input class="button" type="button" name="_7" value="7" onclick="calc(Calc)" /></td> <td><input class="button" type="button" name="_8" value="8" onclick="calc(Calc)" /></td> <td><input class="button" type="button" name="_9" value="9" onclick="calc(Calc)" /></td> <td><input class="button" type="button" name="mul" value="*" onclick="calc(Calc)" /></td> </tr> <tr> <td></td> <td><input class="button" type="button" name="_0" value="0" onclick="calc(Calc)" /></td> <td><input class="button" type="button" name="dot" value="." onclick="calc(Calc)" /></td> <td><input class="button" type="button" name="div" value="/" onclick="calc(Calc)" /></td> </tr> </table> </form> and js Code: function calc(Calc) { var add = eval (document.Calc.add.value); var sub = eval (document.Calc.sub.value); var mul = eval (document.Calc.mul.value); var div = eval (document.Calc.div.value); var clr = eval (document.Calc.clr.value); var _0 = eval (document.Calc._0.value); var _1 = eval (document.Calc._1.value); var _2 = eval (document.Calc._2.value); var _3 = eval (document.Calc._3.value); var _4 = eval (document.Calc._4.value); var _5 = eval (document.Calc._5.value); var _6 = eval (document.Calc._6.value); var _7 = eval (document.Calc._7.value); var _8 = eval (document.Calc._8.value); var _9 = eval (document.Calc._9.value); var dot = eval (document.Calc.dot.value); var equ = eval (document.Calc.equ.value) var output=Calc.Input.value=add+sub+mul+div+clr+_0+_1+_2+_3+_4+_5+_6+_7+_8+_9+dot+equ; document.getElementById("calculator").innerHTML=output; } Can someone help me sort this out? I don't want the images to load until the link is hovered, so for that here is the script but it's not working, can someone help me in correcting it? I added an event listener to each link, and on mouseover called a function that sets the image. To make things more interesting, we can copy lazyload a bit here and also use the data-original property For example: this is the HTML Code: Code: <li> <a href="#" class="tip_trigger"> <img class="tip" alt="300 Grams" data-original="https://lh5.googleusom/-qCRpw.../300%2520.jpg" src='empty.gif' width="90" height="90"/> Alex </a> </li> Then, add an event listener: Code: Code: // call for each element with the class 'tip' that's being hovered upon $('.tip').hover(function() { // retrieve the image inside this element var elem = $(this).find('img'); // set the 'src' to the 'data-original' value elem.attr('src', elem.attr('data-original')); }); for a live demo, you can see this page http://bloghutsbeta.blogspot.com/201...slidernav.html the above part of script is only added to the first letter ALEX in 'A' Category. Okay, ive got 3 css classes. (normalfld, focusfld, and errorfld) When a textbox gets focus, the css class gets set to focusfld, when it looses focus it gets set to normalfld. When a textbox has an error, i set the css class to "errorfld" Now, what I would like to happen is that when a box has been set to "errorfld", when it gets and looses focus, its style will not be changed. This is my first ever attempt at javascripting and im sucking pretty bad. Can someone get me going in the right direction? Here is my attempt, that does not work. It always sets the class, even if the box is set to "errorfld" Code: function DoFocus(fld) { if (fld.classname != 'errorfld') { fld.className = 'focusfld'; } } Any ideas where I went wrong? t.i.a, ~Matt |