JavaScript - Java Background
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> Similar TutorialsI'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 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. 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. 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> I was hoping someone could help me fix this javascript code. I have been working for hours and it does not work. <html> <head> <title>Moondoe's Coffee House</title> </head> <script type="text/javascript"> var drink, ounces; prompt( "Enter the drink type:espresso, latte, cappuccino, americano" ); prompt( "Enter the ounce size: 8, 12, 16" ); var shots = prompt ( "Enter the number of shots" ); if ( drink == "espresso") price = 1.40; if ( drink == "latte") || drink == "cappuccino" ) { if ( ounce == 8 ) price = 1.95; else if ( ounce == 12 ) price = 2.35; else if ( ounce == 16 ) price = 2.75; } if ( drink == "americano" ) price = 1.20 + ( ( (ounce/8) -1 ) * .30 ); price = price + ( (shots-1) * .50 ); price = price * 1.055; price = Math.round ( price*100 ) /100; alert ( "Your " + ounce + "oz. " + drink + "with " + shots + "\nshots of espresso costs: $ " + price ); alert( "drink = " + drink + "ounce = "ounce + "shots = "shots ); </script> </html> please hekp to sort this out.. .. The price of a ticket to a passenger on AOU-Airways is computed based on the following table: [9] Class Price First Class KD 300 Economy Class (with meal) KD 150 Economy Class (without meal) KD 130 Using nested if statements, write a JavaScript code which will work according to the following specifications: a. Read the class that the passenger wants to travel on. b. If the class is the first class, print the price of ticket. c. If the class is the economy class, ask the user if he/she wants a meal on the flight. Then print the price of the ticket according to the response of the passenger. The program should simply accept one possible strings the user enters; it is not required to work for all possible inputs such as First, first, FIRST or Yes , yes, YES. I am no where close to being a coder, but I am looking for a script but I'm not sure where to find this. Basically I got a small email auto responder set up so people receive my tips. Now I want to make it more viral, now I need some code which will log them into there hotmaill/yahoo etc and let me add friends to the bottom of the page and there friends also get the tips to. But, the more friends which confirm, the more tips they get, for example, if 2 confirm they get 15 tips, if 10 confirm they get 50. If you don't understand what I am asking, please, Ill try rephrase it but I think it is a tell a friend script with confirms. Any help is really appreciated, thanks, Lee. 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; } }; Hello all, I am an admin, and I am building a radial button search option on a webpage. It works fine, except I cant seem to get it to open the results in a new window. I tried using the "window.open" but it didnt work. Any assitance would be appreciated! Also, I am not a great java programmer, and what you see below is the extent of my knowledge Thanks in Advance!! ===================CODE=============== <html> <body> <script language="JavaScript">eng = 'http://www.google.com/search?q=';</script> Search: <input type="text" id="searchterms"> <input type="button" value="Search" onload="" onclick="window.location = eng + escape(document.getElementById('searchterms').value); return false;"> <br /> <input type="radio" onclick="eng = this.value;" checked name="sengines" value="http://www.google.com/search?q=" />Google <input type="radio" onclick="eng = this.value;" name="sengines" value="http://support.citrix.com/search/basic/?searchQuery=" />CTX KB <input type="radio" onclick="eng = this.value;" name="sengines" value="http://support.microsoft.com/search/default.aspx?mode=r&query=" />MS KB </body> </html> 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> Hello everyone, I needed some help on finding a complete code which implements DES in either c++ or Java. Thanks 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); } } 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); } } 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. 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 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 i have this code i want to put a java script for this java scrip should be (amt1*amt2)+(amt3)*(amt4)=amt5 if (amt1*amt2)+(amt3)*(amt4) > amt5 should giver mesage on keyup of amount amt4 plzz help me how do i put javascript for this ...........plz help me Code: <table width="1113" height="99" border="0"> <tr bgcolor="#99FF66"> <td width="60"><div align="center"><strong>GROUP ID</strong></div></td> <td width="46"><div align="center"><strong>PART ID</strong></div></td> <td width="97"><div align="center"><strong>ITEM NAME</strong></div></td> <td width="144"><div align="center"><strong>UNIT</strong></div></td> <td width="144"><div align="center"><strong>a/b/c</strong></div></td> <td width="144"><div align="center"><strong>Qty/Crtn</strong></div></td> <td width="144"><div align="center"><strong>Nbr of Crtns</strong></div></td> <td width="144"><div align="center"><strong>Nett Wt/Crt</strong></div></td> <td width="152"><div align="center"><strong>Grs Wt/Crtn</strong></div></td> </tr> <?php $noofrow=0; $result10 = mysql_query("SELECT * FROM Ibws_Data WHERE Sc_No='$PcNo' AND Seq_No='$SeqNo' "); // $row1000 = mysql_fetch_array( $result1000 ); //$Sub_Total=""; while($row10 = mysql_fetch_array( $result10 )) { //$ttlamt=mysql_number_format(); $noofrow++; ?> <tr bgcolor="#99CC66"> <td><label> <?php echo '<input name="Group_ID'.$noofrow.'" value="'.$row10['Group_ID'].'" type="text" size="8" maxlength="12" readonly="readonly" style="text-align:center" />' ; ?> </label></td> <td><label> <?php echo '<input name="Part_ID'.$noofrow.'" value="'.$row10['Part_ID'].'" type="text" size="8" maxlength="12" readonly="readonly" style="text-align:center" />' ; ?> </label></td> <td><label> <?php echo '<input name="Name'.$noofrow.'" value="'.$row10['Name'].'" type="text" size="20" maxlength="25" readonly="readonly" style="text-align:center" />' ; ?> </label></td> <td><label> <?php echo '<input name="Unit'.$noofrow.'" value="'.$row10['Unit'].'" type="text" size="8" maxlength="25" readonly="readonly" style="text-align:center" />' ; ?> </label></td> <td><label> <?php echo '<input name="cat'.$noofrow.'" value="a" type="text" size="8" maxlength="25" readonly="readonly" style="text-align:center" />' ; ?> </label></td> <td><label> <?php echo '<input name="amt1'.$noofrow.'" value="a" type="text" size="8" maxlength="25" readonly="readonly" style="text-align:center" />' ; ?> </label></td> <td><label> <?php echo '<input name="amt2'.$noofrow.'" value="a" type="text" size="8" maxlength="25" readonly="readonly" style="text-align:center" />' ; ?> </label></td> <td><label> <?php echo '<input name="amt3'.$noofrow.'" value="a" type="text" size="8" maxlength="25" readonly="readonly" style="text-align:center" />' ; ?> </label></td> <td><label> <?php echo '<input name="amt4'.$noofrow.'" value="a" type="text" size="8" maxlength="25" readonly="readonly" style="text-align:center" />' ; ?> </label></td> <td><label> <?php echo '<input name="amt5'.$noofrow.'" value="a" type="text" size="8" maxlength="25" readonly="readonly" style="text-align:center" />' ; ?> </label></td> </tr> <tr> <td><label> <input type="submit" name="button" id="button" value="Submit" /> </label></td> <td><label></label></td> <td><label></label></td> <td> </td> <td><label></label></td> <td><label></label></td> </tr> </table> <p> </p> <p> </p> </form> plz help me with a sample java scrip code 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> |