JavaScript - Help Creating Galleries With Java
Hello, I need to resolve a problem.
First, my english may be bad, sorry for this Here's my problem. I'm filling my galleries manually, which is soooo ****ing long. I must change page by page so the most recent tubes be on first one. Here's what I'd like to have : put all my links (divs) in a .txt file for each category, then a script would assemble divs one by one to fill pages. This would be a lot easier to manage my website Thanks for tha help Similar TutorialsWe are working with an Example called Mega Dropdown Menu from AWM. We are looking to change the functionality slighty... Right now when you mouse over Envelopes you get the Submenu the slides out or drops down toward the bottom. That menu has different columns with different links. What we are look to do is this...when we mouse over one of the links, we would like to have the same action that we get when we roll over "Print Services" which is the last Option on the Menu itself. When you mouse over Print Services you get the dropdown or slide out menu that is displaying images. We would like to display just one image, using the same basic code that is being used by "Print Services." I'm sure it is probably a simple piece of JavaScript but I just cant figure it out. Could you please let me know how to do this? Below is the code that the "Print Services" menu is using. Thanks in advance, Bob Attach: Code: <div style="background:#f5f5f5; font-family:Tahoma; font-size:11px; color:#444444; width:auto; height:180px;line-height:20px;"> <p style="color:#39F; font-size:13px; font-weight:bold; margin:10px 20px 8px 20px;">High Quality Offset Printing</p> <p style="color:#39F; font-size:13px; font-weight:bold; margin:10px 15px 8px 15px; white-space:nowrap;"><span class="body"><a href="http://actionenvelope.com/ae/control/printservices/#overview"><img src="http://www.likno.com/examples/awmdata/mega_dropdown_menu2/print.png" alt="1-4 Color Envelope Printing" width="120" height="114" border="0" style="margin:0 20px 0 5px;" /></a></span><span class="body"><a href="http://actionenvelope.com/ae/control/printservices/#options"><img src="http://www.likno.com/examples/awmdata/mega_dropdown_menu2/design.png" alt="Design Online or Upload Your Own File" width="121" height="114" border="0" style="margin-right:20px;" /></a></span><span class="body"><a href="http://actionenvelope.com/ae/control/printservices/#production"><img src="http://www.likno.com/examples/awmdata/mega_dropdown_menu2/production.png" alt="Rush or Standard Production Available" width="120" height="114" border="0" /></a></span></p></div> <div style="background:#FFFFFF; font-family:Tahoma; font-size:11px; color:#444444; border-top:1px solid #BBBBBB; width:auto; height:50px;"> <p style="color:#444444; margin:15px 20px;"><a href="http://actionenvelope.com/ae/control/printservices"><img src="http://www.likno.com/examples/awmdata/mega_dropdown_menu2/goNow.gif" alt="Go Now" width="81" height="21" border="0" align="absmiddle" style="margin-right:20px;" /></a> Learn more about our Envelope Printing services</p> </div> <div style="clear:both;"></div> Thanks, Bob I would like to use the gallery whose code is provided on this page: http://www.meadmiracle.com/SlidingGallery.aspx I tried to display two galleries with the same settings and so I put: $(function() { $('div.gallery img').slidingGallery({ container: $('div.gallery') }); $('div.gallery2 img').slidingGallery({ container: $('div.gallery2') }); }); with the divs being "gallery2" but the coding only works when I put the code without "gallery2". Am I coding it wrong? Is it possible to modify the code I am using in this example to create multiple photo galleries on the same page (basically one for each horse - set up exactly like the example)? There is also some CSS that is connected to this photo gallery. I know CSS a bit more than I know javascript...which I suppose isn't really saying much, since I don't know javascript at all. Also, how much of the code should I post, considering it's a multiple parter? Many thanks! I have been trying to learn java coding from a book and have run into a coding question that I'm confused about. Can someone help? I have a one dimensional array of positive integers. I'm trying to create another array with the same length and scan the original array for finding the maximum integer. I am then needing to copy that maximum integer in first position of the created array and set the maximum integer in the original array to zero. For second round, I need to write code to find the maximum integer in the original array and copy that in second position of created array and set the maximum integer in the original array to zero. I need to repeat this until all numbers in original array is zero. My created array should be sorted in positive integer numbers. I need to write this sort method that accepts a one dimensional array of integers that return the sorted array testing this method using the main method. I'm new to coding, And would like to know if java is capable of: Playing a sound file when a name or word is seen on the screen. Or, In this case on a windows sidebar gadget. Thanks ok, so, I honestly have no clue why it wont work.. I'm workin in html and I put some javascript code(im learnin) so here it is, please help! <script> code = 0 function mf() { code += 1 if (code >= 1) { code = 0 {document.getElementById("test").innerHTML = "I have changed";} } else { code = 1 {document.getElementById("test").innerHTML = "Click below to change me!";} } } </script> <p id = "test">Click below to change me!</p> <button type = "button" onclick = "mf()">click here!</button> What is JAVA? From where I can learn. Please guide me the best institution that is teaching JAVA in the world. Any online tutorial or site where I can get online material. I am not familiar with this program nor i have any idea. I am waiting for your response because i want to start it immediately. hi i want to implement this java script . This is the Original Java script page . Where you see if i click on the yahoo or | google buttons the new window is loading and the same page is displaying with a tab bar menu and close button. I want to implement the same on one of my documents where i created css and java script based drop down menus. But when i tried to implement the same java script on my own page its not working properly.Please help me fix it . I have changed the code only on Button -4 Link-1 only Hers the Live Demo of the page : Live Demo Of the page Heres the Java Script: Java Script Here's the CSS : Code: html,body { padding:0; margin: 0px; background: #306f80; } #wrapper{ width: 1024px; margin-right: auto; margin-left: auto; background: #FFFFFF; height: 1000px; } #header{ height: 100px; width: 1024px; background: url(../images/header.png) repeat-x; } .icons_hold{ float: right; height: 55px; width: 200px; position: relative; top: 10px; right: 10px; } .navestyle{ width: 1024px; font-weight: bold; margin-right: auto; margin-left: auto; } .navestyle:after{ /*Add margin between menu and rest of content in Firefox*/ content: "."; display: block; height: 0; clear: both; visibility: hidden; } .navestyle ul{ border: 1px solid #BBB; width: 100%; background: url(../images/nav_bg.png) repeat-x center center; /*THEME CHANGE HERE*/ padding: 4px 0; margin: 0; text-align: center; font: 12px Verdana, Arial, Helvetica, sans-serif; } .navestyle ul li{ display: inline; margin-right: 2px; margin-left: 2px; } .navestyle ul li a{ color: #494949; padding: 4px 45px 4px 7px; margin: 0; text-decoration: none; border-right: 1px solid #DADADA; } .navestyle ul li a:hover, .navestyle ul li a.selected{ /*script dynamically adds a class of "selected" to the current active menu item*/ background: url(../images/hover.png) repeat-x center center; /*THEME CHANGE HERE*/ color: #FFFFFF; } /* ######### Style for Drop Down Menu ######### */ .dropmenudiv{ position:absolute; top: 0; border: 1px solid #BBB; /*THEME CHANGE HERE*/ border-bottom-width: 0; font:normal 12px/18px Verdana, Arial, Helvetica, sans-serif; z-index:100; background-color: white; visibility: hidden; width: 200px; } .dropmenudiv a{ width: auto; display: block; text-indent: 3px; border-bottom: 1px solid #BBB; /*THEME CHANGE HERE*/ padding: 2px 0; text-decoration: none; font-weight: bold; color: black; } * html .dropmenudiv a{ /*IE only hack*/ width: 100%; } .dropmenudiv a:hover{ /*THEME CHANGE HERE*/ background-color: #F0F0F0; } img { border: none; } .pagination{ padding: 0px 2px 2px; clear: both; } .pagination ul{ margin: 0; padding: 0; text-align: center; /*Set to "right" to right align pagination interface*/ font-size: 16px; } .pagination li{ list-style-type: none; display: inline; padding-bottom: 1px; } .pagination a, .pagination a:visited{ padding: 0 5px; border: 1px solid #9aafe5; text-decoration: none; color: #2e6ab1; } .pagination a:hover, .pagination a:active{ border: 1px solid #2b66a5; color: #000; background-color: #FFCC33; } .pagination a.currentpage{ background-color: #2e6ab1; color: #FFF !important; border-color: #2b66a5; font-weight: bold; cursor: default; } .pagination a.disablelink, .pagination a.disablelink:hover{ background-color: white; cursor: default; color: #929292; border-color: #929292; font-weight: normal !important; } .pagination a.prevnext{ font-weight: bold; } #demoArea { padding: 10px ; height: 580px ; background: #FFFFFF ; /*border: 1px solid black ;*/ /*display: table ;*/ } #demoLinks { width: 20% ; border-right: 1px dotted blue ; float: left ; } #demoBrowser { position: relative; width: 950px; margin-left: auto; margin-right: auto; } #tabBrowser { position: absolute ; width: 100% ; } /* --------------- TABS -------------------*/ #tabDemo { display: none } #tabContainer { display: block ; } #tabs { cursor: default ; list-style-type: none ; /*width: 560px ;*/ margin: 0 ; padding: 0 ; } #tabs li { background: #FFFBF0 ; border: 1px solid green ; border-bottom: 0 ; -moz-border-radius-topleft: 5px ; -moz-border-radius-topright: 5px ; float: left ; width: 100px ; min-width: 35px ; height: 20px ; margin: 0 2px 3px 0 ; padding-left: 3px ; } .tabTitle { float: left ; width: 80% ; height: 100% ; overflow: hidden ; } .closeTab { text-align: center ; text-transform: uppercase ; margin: 2px 3px 2px 80% ; border: outset 1px #D40000 ; } .closeTab:hover { background: #000000; } /* --------------- BROWSER -------------------*/ #tabContent { position: relative ; clear: both ; width: 100% ; } #tabContent div { position: absolute ; width: 100% ; } Here's the Mark Up : 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" lang="en" xml:lang="en"> <head> <title>Testing page</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <link rel="stylesheet" type="text/css" href="css/css.css" /> <script type="text/javascript" src="js/tabbed_browser.js"></script> <script type="text/javascript" src="js/chrome.js"> </script> </head> <body> <div id="wrapper"> <div id="header"> <div class="icons_hold"><a href="#"><img src="images/home.png" title="home" /></a> <a href="#"><img src="images/help.png" title="help" /></a> <a href="#"><img src="images/sign_out.png" title="signe out" /></a></div> </div> <div class="navestyle" id="navemenu"> <ul> <li><a href="#" title="chaitnyas testing page">Button-1</a></li> <li><a href="#" title="chaitnyas testing page">Button-2</a></li> <li><a href="#" title="chaitnyas testing page">Button-3</a></li> <li><a href="#" rel="dropmenu1" title="chaitnyas testing page">Button-4</a></li> <li><a href="#" rel="dropmenu2" title="chaitnyas testing page">Button-5</a></li> <li><a href="#" rel="dropmenu3" title="chaitnyas testing page">Button-6</a></li> <li><a href="#" title="chaitnyas testing page">Button-7</a></li> <li><a href="#" title="chaitnyas testing page">Button-8</a></li> </ul> </div> <!--1st drop down menu --> <div id="dropmenu1" class="dropmenudiv"> <a id="link1" onclick="openTab('link1')" href="http://yahoo.com." title="chaitnyas testing page" ><img src = "images/1.gif" /> Link-1</a> <a href="link-2.htm" title="chaitnyas testing page"><img src = "images/2.gif" /> Link-2</a> <a href="link-3.htm" title="chaitnyas testing page"><img src = "images/3.gif" /> Link-3</a> <a href="link-4.htm" title="chaitnyas testing page"><img src = "images/4.gif" /> Link-4</a> <a href="link-5.htm" title="chaitnyas testing page"><img src = "images/5.gif" /> Link-5</a></div> <!--2nd drop down menu --> <div id="dropmenu2" class="dropmenudiv" style="width: 150px;"> <a href="#" title="chaitnyas testing page"><img src = "images/6.gif" /> Link-1</a> <a href="#" title="chaitnyas testing page"><img src = "images/7.gif" /> Link-2</a> <a href="#" title="chaitnyas testing page"><img src = "images/8.gif" /> Link-3</a></div> <!--3rd drop down menu --> <div id="dropmenu3" class="dropmenudiv" style="width: 150px;"> <a href="#" title="chaitnyas testing page"><img src = "images/9.gif" /> Link-1</a> <a href="#" title="chaitnyas testing page"><img src = "images/10.gif" /> Link-2</a> <a href="#" title="chaitnyas testing page"><img src = "images/11.gif" /> Link-3</a></div> <script type="text/javascript"> cssdropdown.startchrome("navemenu") </script> <p><br /> <div id="demoBrowser"> <div id="tabBrowser"> <div id="tabContainer"> <ul id="tabs"><li id="tabDemo"><div class="tabTitle">Google</div><div class="closeTab">x</div></li> </ul> </div> <div id="tabContent"> </div> </div> </div> </div><br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> </p> <div class="pagination"> <ul> <li><a href="products.htm" class="currentpage" title="Products">1</a></li> <li><a href="products1.htm" title="Products">2</a></li> <li><a href="products2.htm" title="Products">3</a></li> </ul> </div><br /> </p> </div> </body> </html> Can someone help tell me where i've gone wrong! My finished script works in all browser except IE in IE it works on some machines not others, if i put the finesed page in a Iframe on another site it works but not in the original URL and on my machine it works if i go directly to the URL however if i hit refresh it doesn't work until i go directly to the URL again! In developer tools it comes up with the following error: SCRIPT5022: DOM Exception: TYPE_MISMATCH_ERR (17) cgl.js, line 147 character 3 here is the script it is referring too! Please help!!! PHP Code: var CGL = {}; CGL.canvas = { DEFAULT_CONTEXT : "2d", DEFAULT_CANVAS_ID : "cglcanvas", CANVAS_CONTAINER : "", CANVAS_WIDTH : 300, CANVAS_HEIGHT : 200, TARGET_FPS : 60, setDefault : function(option, value){ CGL.canvas[option] = value; }, getDefault : function(option){ return CGL.canvas[option]; }, /** * @method createCanvas(id, width, height) * @param id : sets the CANVAS_CONTAINER * @param width : sets the CANVAS_WIDTH * @param height : sets the CANVAS_HEIGHT * * Creates a <canvas> element that will be used as the main graphics container for the game! */ createCanvas : function(id, width, height){ var canvas = document.createElement("canvas"); CGL.canvas.CANVAS_WIDTH = width; CGL.canvas.CANVAS_HEIGHT = height; CGL.canvas.CANVAS_CONTAINER = id; canvas.setAttribute("width", width); canvas.setAttribute("height", height); canvas.style.borderColor = "black"; canvas.style.borderStyle = "solid"; canvas.style.borderWidth = "1px"; canvas.setAttribute("id", CGL.canvas.DEFAULT_CANVAS_ID); document.getElementById(id).appendChild(canvas); var elem = document.createElement("div"); elem.setAttribute("id", "status"); elem.style.width = width + "px"; elem.style.height = "120px"; elem.style.overflowY = "scroll"; elem.style.borderColor = "black"; elem.style.borderStyle = "solid"; elem.style.borderWidth = "1px"; elem.style.color = "black"; elem.style.backgroundColor = "white"; elem.style.display = "none"; document.getElementById(id).appendChild(elem); }, /** * @method getContext() * * Returns the graphic context as chosen by the DEFAULT_CONTEXT global. */ getContext : function(){ var canvas = document.getElementById(CGL.canvas.DEFAULT_CANVAS_ID); return canvas.getContext(CGL.canvas.DEFAULT_CONTEXT); } }; CGL.image = { IMAGE_ID : 0, DEFAULT_IMAGECONT_ID : "imgcont", createImageContainer : function() { var div = document.createElement("div"); div.setAttribute("id", CGL.image.DEFAULT_IMAGECONT_ID); div.style.display = "none"; document.body.appendChild(div); }, load : function(src, id){ var img = document.createElement("img"); img.setAttribute("src", src); img.setAttribute("id", id); img.setAttribute("onload", "notifyLoaded(" + id + ")"); document.getElementById(CGL.image.DEFAULT_IMAGECONT_ID).appendChild(img); }, Image : function(source, uid, srcx, srcy){ var img = { id : uid, x : srcx, y : srcy }; CGL.image.load(source, uid); return img; }, render : function(ctx, img){ ctx.drawImage(document.getElementById(img.id), img.x, img.y); }, renderAt : function(ctx, imgid, x, y){ ctx.drawImage(document.getElementById(imgid), x, y); }, renderPart : function(ctx, imgid, srcx, srcy, srcwidth, srcheight, destx, desty, destwidth, destheight){ ctx.drawImage(document.getElementById(imgid), srcx, srcy, srcwidth, srcheight, destx, desty, destwidth, destheight); } }; CGL.sprite = { Sprite : function(frames, time){ var sprite = { active : true, speed : time || 500, activeFrame : 0, maxFrames : frames.length - 1, images : frames, timeCount : 0, loop : true, nextFrame : function(){ sprite.activeFrame += 1; if(sprite.activeFrame > sprite.maxFrames) { if(sprite.loop) { sprite.activeFrame = 0; } else { sprite.activeFrame = 0; sprite.active = false; } } }, setSpeed : function(time){ sprite.speed = time; }, setLoop : function(looping){ sprite.loop = looping; }, setActiveFrame : function(actFrame){ sprite.activeFrame = actFrame; }, stop : function(){ sprite.active = false; }, start : function(){ sprite.active = true; }, replay : function(){ sprite.activeFrame = 0; sprite.active = true; }, update : function(time){ if(sprite.active) { sprite.timeCount += time; } if(sprite.timeCount > sprite.speed) { sprite.nextFrame(); sprite.timeCount = 0; } }, render : function(ctx, x, y){ ctx.drawImage(document.getElementById(sprite.images[sprite.activeFrame]), x, y); } }; return sprite; } }; CGL.resource = { RESOURCES : 0, loadImages : function(xml){ var image, elem, i; var img = new Array(); var imgsrc, imgid; xmlhttp = CGL.ajax._createXHR(); xmlhttp.onreadystatechange = function(){ if (xmlhttp.readyState==4 && xmlhttp.status==200){ image = xmlhttp.responseXML.documentElement.getElementsByTagName("image"); for(i = 0; i < image.length; i++){ elem = image[i].getElementsByTagName("src"); try{ imgsrc = elem[0].firstChild.nodeValue; } catch(er){ } elem = image[i].getElementsByTagName("id"); try{ imgid = elem[0].firstChild.nodeValue; } catch(er){ } CGL.image.load(imgsrc, imgid); img[i] = imgid; CGL.resource.RESOURCES++; CGL.util.printLn("Loaded Image: " + imgsrc + " With ID: " + imgid); } } }; xmlhttp.open("GET",xml,false); xmlhttp.send(); return img; } }; CGL.highscore = { highscore : function(url, posts) { var highScore = { name : new Array(posts), score : new Array(posts), level : new Array(posts), size : posts, getHighScore : function() { highScore.size = 10; xmlhttp = CGL.ajax._createXHR(); xmlhttp.onreadystatechange = function() { if (xmlhttp.readyState == 4 && xmlhttp.status == 200) { var string = xmlhttp.responseText; var list = eval( "(" + string + ")" ); for(i = 0; i < list.length; i++){ highScore.name[i] = list[i].name; highScore.score[i] = list[i].score; highScore.level[i] = list[i].level; } highScore.size = list.length; } } xmlhttp.open("GET",url + "?action=get&posts=" + highScore.size ,false); xmlhttp.send(); }, recordHighScore : function(name, level, score) { xmlhttp = CGL.ajax._createXHR(); xmlhttp.onreadystatechange = function() { if (xmlhttp.readyState == 4 && xmlhttp.status == 200) { CGL.util.printLn(xmlhttp.responseText); } } xmlhttp.open("GET",url + "?action=put&name=" + name + "&score=" + score + "&level=" + level ,false); xmlhttp.send(); }, reInit : function() { for(var i = 0; i < highScore.size; i++) { delete highScore.name[highScore.size-i]; delete highScore.score[highScore.size-i]; delete highScore.level[highScore.size-i]; } } }; return highScore; } }; CGL.ajax = { _createXHR : function() { try { return new XMLHttpRequest(); } catch(e) {} try { return new ActiveXObject("Msxml2.XMLHTTP.6.0"); } catch (e) {} try { return new ActiveXObject("Msxml2.XMLHTTP.3.0"); } catch (e) {} try { return new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) {} try { return new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {} return null; } }; CGL.util = { MESSAGE_ID : 0, LASTUPDATE : 0, UPDATE_RPS : 40, printLn : function(message) { var elem = document.createElement("p"); elem.setAttribute("id", CGL.util.MESSAGE_ID); document.getElementById("status").appendChild(elem); document.getElementById(CGL.util.MESSAGE_ID).innerHTML = CGL.util.MESSAGE_ID + " : " + message; CGL.util.MESSAGE_ID++; }, gameTimer : function() { delta = new Date(); if(delta.getTime() > CGL.util.LASTUPDATE + 1000/CGL.util.UPDATE_RPS) { CGL.util.LASTUPDATE = delta.getTime(); return true; } else return false; }, }; CGL.math = { Vector2 : function(vx, vy) { var Vector2 = { x : vx || 0.0, y : vy || 0.0, interpolate : function(a_vec, b_vec, a_f){ return a_vec.mul(a_f).add(b_vec.mul(1-a_f)); }, mul : function(other){ Vector2.x *= other.x; Vector2.y *= other.y; }, mulScale : function(scale) { Vector2.x *= scale; Vector2.y *= scale; }, sub : function(other) { Vector2.x -= other.x; Vector2.y -= other.y; }, add : function(other) { Vector2.x += other.x; Vector2.y += other.y; }, div : function(other) { Vector2.x /= other.x; Vector2.y /= other.x; }, divScale : function(scale) { Vector2.x /= scale; Vector2.y /= scale; }, scale : function(a_f, a_g){ return new CGL.math.Vector2d(a_f * Vector2d.m_x, a_g * Vector2d.m_y); }, dot : function(other) { return ((Vector2.x * other.x) + (Vector2.y * other.y)); }, neg : function() { return new CGL.math.Vector2(-Vector2.x, -Vector2.y); }, normalize : function() { var l = Vector2.length(); if(l == 0){ return; } Vector2.x /= l; Vector2.y /= l; }, lengthSquared : function() { return (Vector2.x * Vector2.x) + (Vector2.y * Vector2.y); }, length : function() { return Math.sqrt(Vector2.lengthSquared()); }, toString : function() { return "[Vector (" + Vector2.x + ", " + Vector2.y + ")]"; }, copy : function(other) { Vector2.x = other.x; Vector2.y = other.y; }, draw : function(ctx) { /* Convert to Local space */ var lx, ly; if(Vector2.x < 0.0) { lx = (-Vector2.x * -50) + 200; } else { lx = (Vector2.x * 50) + 200; } if(Vector2.y > 0.0) { ly = (Vector2.y * -50) + 200; } else { ly = (-Vector2.y * 50) + 200; } ctx.beginPath(); ctx.arc(lx, ly, 2, 0, Math.PI*2, true); // Outer circle ctx.fill(); } }; return Vector2; }, getNormal : function(vx, vy) { var n = new CGL.math.Vector2(vy.x, vy.y); n.sub(vx); n = new CGL.math.Vector2(n.y, -n.x); n.normalize(); return n; } }; CGL.ui = { Button : function(imgs, srcx, srcy, srcwidth, srcheight) { var button = { images : imgs, x : srcx, y : srcy, width : srcwidth, height : srcheight, active : false, clicked : false, update : function(mx, my, mb) { if(mx > button.x && mx < button.x + button.width && my > button.y && my < button.y + button.height) { button.active = true; } else { button.active = false; } if(button.active && mb) { button.clicked = true; } }, activated : function() { return button.clicked; }, deactivate : function() { button.clicked = false; }, render : function(ctx) { if(!button.active) { ctx.drawImage(document.getElementById(button.images[0]), button.x, button.y); } else { ctx.drawImage(document.getElementById(button.images[1]), button.x, button.y); } } }; return button; } }; CGL.event = { MOUSEX : 0, MOUSEY : 0, KLEFT : false, KRIGHT : false, KDOWN : false, KUP : false, KSPACE : false, KPAUSE : false, CLICKED : false, ACTIVEGAMEKEY : true, handleEventMovement : function(e) { CGL.event.getCursorPosition(e); }, handleEventClick : function(e) { CGL.event.CLICKED = true; }, clearEvents : function() { CGL.event.KLEFT = false; CGL.event.KRIGHT = false; CGL.event.KDOWN = false; CGL.event.KUP = false; CGL.event.KSPACE = false; CGL.event.KPAUSE = false; CGL.event.CLICKED = false; }, handleEventKey : function(e) { if(CGL.event.ACTIVEGAMEKEY) { e.stopPropagation(); e.preventDefault(); } switch(e.keyCode) { case 19: CGL.event.KPAUSE = true; break; case 32: CGL.event.SPACE = true; CGL.util.printLn("Space was triggered!"); break; case 37: CGL.event.KLEFT = true; break; case 38: CGL.event.KUP = true; break; case 39: CGL.event.KRIGHT = true; break; case 40: CGL.event.KDOWN = true; break; case 65: CGL.event.KLEFT = true; CGL.util.printLn("Left was triggered!"); break; case 87: CGL.event.KUP = true; CGL.util.printLn("Up was triggered!"); break; case 68: CGL.event.KRIGHT = true; CGL.util.printLn("Right was triggered!"); break; case 80: CGL.event.KPAUSE = true; break; case 83: CGL.event.KDOWN = true; CGL.util.printLn("Down was triggered!"); break; default: break; }; }, getCursorPosition : function(e) { if (e.pageX != undefined && e.pageY != undefined) { CGL.event.MOUSEX = e.pageX; CGL.event.MOUSEY = e.pageY; } else { CGL.event.MOUSEX = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft; CGL.event.MOUSEY = e.clientY + document.body.scrollTop + document.documentElement.scrollTop; } CGL.event.MOUSEX -= document.getElementById(CGL.canvas.DEFAULT_CANVAS_ID).offsetLeft; CGL.event.MOUSEY -= document.getElementById(CGL.canvas.DEFAULT_CANVAS_ID).offsetTop; } }; hi, i have a html form and i have three text boxes named Max Accessories: Accessory SKU: Accessory CPC ID: and i want a javascript functionality like, if the user enters in the max accessories text box value as 1, then the below two text boxes should update like automatically like below, AcceSsory 1 SKU ACCESSORY 1 CPC ID SIMILARLY if user enters Max accessories value as 2 in the text box, then the below two text boxes should update like automatically like below AcceSsory 1 SKU ACCESSORY 1 CPC ID AcceSsory 2 SKU ACCESSORY 2 CPC ID onchange of the key, for accessory it should call some function in the same page and dynamically update. can any one please provide, a solution for this , thanks. Hi Chaps, I'm looking for a 'preloader' progress bar to appear whilst a file is uploaded/downloaded from my php app. Not sure whether this is a Java/Flash question, but any help would be appreciated. Cheers I need good java coder to join to make website to new Gaming croup, we cannot pay you anything but job is not that big eighter, so if here is someone who could help to make this one website i would be very happy. Thanks! Kalmah Hey guys! I have this website mmosaga.com and in need of some help to fix my BG. Im trying to get my BG to rescale to various of monitor sizes. My monitor width is 1440 and my BG images are Width: 1566 Height:768. I want that position to show up on all the other browsers including IE. Here the code I use PHP Code: <html> <head> <script language="javascript"> function randomBackground() { var myImages = Array(); myImages[0] = 'Florenga.jpg'; myImages[1] = 'pangar.jpg'; myImages[2] = 'GrandChaseBG.png'; myImages[3] = 'ADBG.png'; myImages[4] = 'AionBG.png'; myImages[5] = 'FiestaBG.jpg'; myImages[6] = 'GalaxyOnlineBG.jpg'; myImages[7] = 'GunzBG.png'; myImages[8] = 'IrisOnlineBG.png'; myImages[9] = 'MabinogiBG.png'; myImages[10] = 'APB.jpg'; myImages[11] = 'S4LeagueBG.jpg'; myImages[12] = 'APB.jpg'; myImages[13] = 'WorldOfTanksBG.jpg'; myImages[14] = 'Elsword.jpg'; myRandomNumber = Math.floor(Math.random()*myImages.length); document.body.style.backgroundImage = 'URL('+myImages[myRandomNumber]+')'; } </script> <style type="text/css"> body { background-attachment: fixed; background-repeat: no-repeat; } </style> </head> <body onload="randomBackground();"></body> Im having problems with the following code and not sure why it only seems to be a problem when i call for the amount1 variable in the discountedPriceString variable it returns as undefined. but if i just request amount1 in the alert it works fine. Could someone just explain where i have gone wrong Thanks Code: <script> DISCOUNT_RATE = 0.25; var price = parseFloat(prompt('Enter the normal price','0.00')); var discountedPriceString = 'The sale price is $' +amount1 ; var amount1 = ''; // Apply the discount to the price discount1 = price * DISCOUNT_RATE; amount1 = price - discount1 // Add the new price to the string using toFixed() amount1 = (amount1.toFixed(2)); alert(discountedPriceString); </script> Im writing this code for a gas station program. I have been writing and improving my code for about 3 weeks now and its quite long. I have about classes , customer class, office class and a gas pumps classes. I need help on how to get started on finding the total output at the end of the day. Conceptually i know what i have to do but I don't know where to begin writing the code. I think each time there is a new customer i should add the amount of fuel purchased to a new total fuel purchases variable in the gas pump class. If any one could give me some advice or tips on my theory it would be great ! Should I create a method or can i be done without one. Code: import java.util.Random; import java.util.Scanner; public class Customer { private String carTag; private double gasPurchased; private int gasType; public Customer () { Random gen = new Random ( ); carTag = ""; for (int i = 1; i <= 6; i++) { //a random number between 48 and 90 int code = gen.nextInt (43)+ 48; if ((code <= 64) && (code >= 58)) { i--; continue; } carTag += ((char)(code)); } System.out.println ("a car arrives; tag number:" + carTag); } public int getGasType () { Scanner inputDevice = new Scanner (System.in); //1:regular, 2:plus, 3:premium System.out.println ("enter type of gas to buy " + "(1:regular, 2:plus, 3:premium): "); gasType = inputDevice.nextInt (); return gasType; } public double getGasPurchased () { Random gen = new Random (); gasPurchased = gen.nextDouble ()* 50; return gasPurchased; } public String getCarTag () { return carTag; } Code: import java.util.Random; public class Office { public static void main (String [ ] args) { double regularTank = 1000; double plusTank = 1000; double primiumTank = 1000; GasPump pump1 = new GasPump ( ); GasPump2 pump2 = new GasPump2 ( ); Random gen = new Random (); //asuumint gas tanks always have gas, will upgrade later do { int whatHappens = gen.nextInt (100); if (whatHappens == 5) { System.out.println ("gas station closed"); break; } else if ((whatHappens % 10) == 0) { if (pump1.pumpAvailable ()) pump1.customerArrival (); else System.out.println ("a new customer arrives at pump 1, but is turned away, gas pump is busy"); } else { if (pump1.pumpAvailable ()) System.out.println ("no customer; waiting........."); } if (!pump1.pumpAvailable()) { if (pump1.updateClock () == 0) pump1.saleComplete (); } } while (true); do system.exit () Code: public class GasPump { final private double REGULAR_PRICE = 3.15; final private double PLUS_PRICE = 3.5; final private double PREMIUM_PRICE = 4.5; final private double HOSE_FLOW_RATE = 0.85; private double totalPayment; private Customer who; private int timeLeftToFinish; private int gasType; private double gasPurchased; private String carTag; public GasPump () { who = null; totalPayment = 0; timeLeftToFinish = 0; } public void customerArrival () { who = new Customer (); System.out.println ("welcome to jack's gas station PUMP 1 "); gasType = who.getGasType (); gasPurchased = who.getGasPurchased (); timeLeftToFinish = (int)(gasPurchased/HOSE_FLOW_RATE); System.out.println (timeLeftToFinish + " total time units needed for this transaction..."); carTag = who.getCarTag (); } private void printReceipt ( ) { System.out.println ("****Sale Receipt"); switch (gasType) { case 1: System.out.println ("regular gas"); break; case 2: System.out.println ("plus gas"); break; case 3: System.out.println ("premium gas"); break; } System.out.println ("gas amount: " + gasPurchased + "\ntotal payment" + totalPayment + "\nthank you"); System.out.println("Pump has " + regularTank()); } private void resetPump ( ) { who = null; totalPayment = 0; timeLeftToFinish = 0; } public int updateClock () { timeLeftToFinish--; System.out.println (timeLeftToFinish + " time units left to finish "); return timeLeftToFinish; } public void saleComplete ( ) { switch (gasType) { case 1: totalPayment = REGULAR_PRICE * gasPurchased; break; case 2: totalPayment = PLUS_PRICE * gasPurchased; break; case 3: totalPayment = PREMIUM_PRICE * gasPurchased; break; } printReceipt ( ); resetPump ( ); } public boolean pumpAvailable () { return (who == null); } } Can someone help me with this javascript? It works fine with 10 images, but when I add the 11th it will not rotate the 11th image but still rotate the 1st 10. <br> <script type="text/javascript"> var imgs1 = new Array("/resource/resmgr/Ad_Banner/ad16.jpg","/resource/resmgr/Ad_Banner/ad13.jpg","/resource/resmgr/Ad_Banner/ad14.jpg","/resource/resmgr/Ad_Banner/ad8.jpg","/resource/resmgr/Ad_Banner/ad15.jpg","/resource/resmgr/Ad_Banner/ad18.jpg","/resource/resmgr/Ad_Banner/ad12.jpg","/resource/resmgr/Ad_Banner/ad19.jpg","/resource/resmgr/Ad_Banner/ad20.jpg","/resource/resmgr/Ad_Banner/ad21.jpg","/resource/resmgr/Ad_Banner/ad21.jpg","/resource/resmgr/ad_Banner/ad3.jpg"); var lnks1 = new Array("http://www.adamscollision.com","http://www.huntleyrealty.com","http://www.trinitycpraed.com","http://www.sccah.com/?page=SCFestival","http://www.blazekshomefurnishings.hdspd.com","http://www.sccah.com/?page=JB_Const","http://tgconsultantsinc.com/","http://blueskiespilotshop.com/index.html ","http://www.aaaglass.com/ ","http://www.carytravelexpress.com/","http://www.sccah.com/?page=Ad_Inquiry "); var alt1 = new Array("Adams Collision","Huntley Realty","Trinity","Sun City Arizona","Hunter Douglas Window Coverings and Custom Draperies","J&B Construction","TGI Consulting","Blue Skies","AAA Glass","Cary Travel Express","THIS COULD BE YOUR AD!!!"); var currentAd1 = 0; var imgCt1 = 11; function cycle1() { if (currentAd1 == imgCt1) { currentAd1 = 0; } var banner1 = document.getElementById('adBanner1'); var link1 = document.getElementById('adLink1'); banner1.src=imgs1[currentAd1] banner1.alt=alt1[currentAd1] document.getElementById('adLink1').href=lnks1[currentAd1] currentAd1++; } window.setInterval("cycle1()",4000); </script> <a href=""http://www.adamscollision.com"" id="adLink1" rel="nofollow" target="_blank"> <img src="/resource/resmgr/Ad_Banner/ad16.jpg" id="adBanner1" border="0" width="170" height="200"></a> I'm not really good with javascript and need help with a problem. I'm creating a pop-up window that goes to another site but sends the url it's coming from in the url it's going to. Ok here's what I have if that's confusing. Code: <head> <script type="text/javascript"> function popupwin(url) { var width = 650; var height = 250; var left = (screen.width - width)/2; var top = (screen.height - height)/2; var params = 'width='+width+', height='+height; params += ', top='+top+', left='+left; params += ', scrollbars=1'; newwin=window.open(url,'popupwin', params); if (window.focus) {newwin.focus()} return false; } </script> </head> <body> <a href="javascript: void(0)" onClick="popupwin('http://example.com/check.php?id=http://$_SERVER[SERVER_NAME]$_SERVER[REQUEST_URI]'); return false;">Centered popup window</a> </body> Now that above code works fine in most cases and on most sites. The problem is that one forum I've tried it on has a seo mod which means the php comand $_SERVER[REQUEST_URI] isn't the same that's in the address bar. Instead of showing Code: http://sitename.com/forum/main-forum/1-test-post-title-some-list.html it's showing Code: http://sitename.com/forum/showthread.php?p=1 After Googling I know that document.write(location.href) will give me the exact url of the seo url as it appears in the address bar which is what I want. Can anyone show me how to combine document.write(location.href) with my code. I know it's probably easy for most but I only really know basic html and php and I'm only new to javascript. Thanks in advance. how to get first 4 digits of mobile number using substing method and then how to check that number in if condition using java script.that is i entered the mobile number 9688786064.i want to check first four digits 9688 .in that same check all the entered number only 9688 started nymber can allow to store data base..how can i develop the program..plz help me var ph1=document.getElementById('ph'); ph1=ph.substring(0,4) is it correct or not .if it is correct then tell further steps.if it wrong tell me the correct code this is what i have so far but im having trouble adding an accessor method for answer which i have called getAnswer public class Question { private String text; private String answer; private String getAnswer; /** * Constructs a question with empty question and answer. */ public Question() { text = ""; answer = ""; } /** * Sets the question text. * @param questionText the text of this question */ public void setText(String questionText) { text = questionText; } /** * Sets the answer for this question. * @param correctResponse the answer */ public void setAnswer(String correctResponse) { answer = correctResponse; } public String getAnswer(){ return answer; } /** * Checks a given response for correctness. * @param response the response to check * @return true if the response was correct, false otherwise */ public boolean checkAnswer(String response) { return response.equals(answer); } /** * Displays this question. */ public void display() { System.out.println(text); } } |