JavaScript - Simple Java Program Help
Hey guys,
Here's the program. Quote: import java.util.Random; import java.util.Scanner; public class HighLowGame { public static void main(String[] args) { Random rand = new Random(); int numberOfTries = 0; Scanner input = new Scanner(System.in); char repeat; char ans; int guess; boolean win = false; do { System.out.println("Pick a number between 0 and 10: "); guess = input.nextInt(); numberOfTries++; int numberToGuess = rand.nextInt(10); if (guess == numberToGuess) { win = true; System.out.println("Congratulations you have won!"); } else if (guess > numberToGuess) { System.out.println("Your guess was high try again"); } else if (guess < numberToGuess) { System.out.println("Your guess was low try again"); } System.out.println("The number was " + numberToGuess); System.out.println("You guessed the number in "+ numberOfTries + " attempt(s)"); System.out.println("New game? 1 for Yes, or any other number to quit "); ans = input.next().charAt(0); } while (ans == 1); } } Two questions, why doesn't my program let me keep putting in numbers until I guess the right one? What is wrong with my loop? Pressing 1 should repeat the program, any other number should close. Thanks! Similar TutorialsIm 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); } } Hi im trying to make a program that passes an array to a method. the method then finds the smallest number in the array and passes that number back to the main where its printed out. I am getting an error saying: "error: number cannot be resolved to a variable". I am using drjava. here is my code. Code: import java.util.*; public class homeWorkTwo{ public static void main(String[] args) { int[] arrayA; arrayA = new int[10]; arrayA[0]=7; arrayA[1]=5; arrayA[2]=8; arrayA[3]=9; arrayA[4]=2; arrayA[5]=10; arrayA[6]=11; arrayA[7]=1; int lowestNumber = find_sum(number); System.out.print("The smallest number is: "+lowestNumber); } public static int find_sum(int [ ] arrayB){ int isItSmaller=0; int small=0; System.out.println("poop"); for(int i=0;i<=7;i++){ isItSmaller=arrayB[i]; if(small<isItSmaller){} else small=isItSmaller; } System.out.print(small); return small; } } Hi everyone , I have been working with java script for a couple of weeks now and have run into some practice obstacles, ok so I am trying to build a html java program for my website and I wants there to be a web page in which users can dynamically change the styles of page elements (e.g.,background, text) by typing the style name into a dialog box. So basically enter a word and the that word should be set to change the attributes once entered in. Ive tried working with if else statements but have run into many problems. Again I am a beginner and am trying to self teach myself if you all could help me that would be great. Thanks Sash JAVA not JavaScript create an application, searcher that takes two command line arguments: the starting directory and the target to find. Searcher makes use of a recursive algorithm with the method signatu public static void scan (String path). This recursive algorithm needs to scan through directories and over file names in order to locate the specified file from the command line. You will, in all likelihood, need to make your FileIOHelper class described below. once you located your file you can stop executing and display the output of where the file was located. Create a class called FileIOHelper. This has two private String arrays, directories and files. It also includes two public instance int variables dirLength and fileLength witch stores length of directories and files String arrays respectively. it has one constructor that takes a file object, witch is used to determine the directory where you are going to be getting the information from. the constructor needs to iterate through each array element provided and assign the String to the right array(it's either a dir or file). Your arrays need to resize properly as you iterate through them. The fileIOHelper has two public methods, getDirectories() and getFiles() both return their respective protected String arrays. The FileIOHelper also has 2 private methods addToFile() and addToDirectory() witch both take a String and return a String array extra 1)keeping track of witch stack your working on currently - loggin information to a file through a static logger class. 2)using assertions where posible. Hi, I need help with this magic square program. I included the instructions and there are a few sample runs to get an idea of what the program is suppose to come out as. Would be helpful if the most basic java language is used. Willing to PayPal money to whoever gets the program correct. Thank you. Write a program named Median.java that asks the user for three integers and outputs the median. I have to do this using if else statements. It seems really easy, but I can't figure it out. Help! Here's my code: Code: import java.util.*; public class Median { public static void main(String[] args) { Scanner console = new Scanner(System.in); System.out.println("Please enter number 1"); int max = console.nextInt(); int min = max; int median = min; for (int i=2; i <= 3; i++) { System.out.println("Please enter number "+i); int enteredNumber = console.nextInt(); if (enteredNumber > max) { max = enteredNumber; } else { enteredNumber = median; } if (enteredNumber < min) { min = enteredNumber; } else { enteredNumber = median; } } System.out.println("The median is: "+median); } } When I run this it just gives me back the first number I entered. Basically i have an image of a ball that i am trying to make bounce from top to bottom so far it is just going to the bottom and stopping plz help thanks <head> <title></title> </head> <body> <center> <input type="button" value="Click" onClick="moveDown()"/> </center> <img id="Ball" src="ball.jpg" style="position:absolute; top:100px; left:100px;"/> <script language="JavaScript"> var Image = document.getElementById("Ball"); var Position = 100; var direction = 1; function moveDown() { if(direction > 0) { Image.style.top = parseInt(Image.style.top) + 20+'px'; } if(parseInt(Image.style.top)> 100 || direction > 1 ) direction = 1 if(parseInt(Image.style.top)> 500 || direction < 1 ) { direction = -1 Image.style.top = parseInt(Image.style.top) - 20+'px'; } } setInterval ("moveDown()", 50 ); </script> </body> </html> I am trying to make a fairly simple program for practicing for a mid-term that is coming up in my intro to programming class and I need some help figuring out how to create the function/setting up the variables. Essentially what the code is, is a program that adds up the values put in 5 text boxes, the values from checkboxes that are selected, and the value of a selected radio button. I do not think I have the variables named correctly, and I have no idea how to create the function. I will post what I have so far so you can get a better idea of what it is I'm trying to make. It's so simple, just adding up everything. I just need help figuring out how to achieve that... Here is the code I have so far: <!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>Computer Price Caculator</title> <script type="text/javascript"> function calc() { with( document.frmCom ) { var P = setPerepherals.selectedIndex; var S = setShipping.selectedIndex; var total = P + S; display.value = "Your systems total price is:" setPerepherals.value[P].text + setShipping.value[S].text + "\n Total:\t$" + total.toFixed(2); }//end with }//end calc() </script> <style type="text/css"> .auto-style1 { margin-left: 17px; } </style> </head> <body background="PracticeMidterm/bg.jpg"> <center> <h1> <img src="PracticeMidterm/Computer.jpg" height="124" width="179">Computer Price Calculator</h1> <hr class="auto-style1" style="width: 784px" /> <form name="frmCom"> <table style="border:thin black solid"> <tr> <td colspan="2" width="700" align="center"> Processor (CPU): <input type="text" align="middle" name="textCPU"></input> <br/> Motherboard: <input type="text" name="textMotherboard" ></input><br/> Case: <input type="text" name="textCase" ></input><br/> Power Supply: <input type="text" name="textPowersupply" ></input><br/> Monitor: <input type="text" name="textMonitor" ></input> </td></tr> <tr> <td align="center"><hr width="500" align="center" /></td> </tr> <tr> <td colspan="1" align="center"> Perepherals: <input type="checkbox" align="middle" name="checkboxKeyboard" value="25.00" onclick="setPerepherals()" >Keyboard ($25.00)</input> <br/><input type="checkbox" align="middle" name="checkboxMouse" value="10.00" onclick="setPerepherals()" >Mouse ($10.00)</input> <br/><input type="checkbox" align="middle" name="checkboxTablet" value="60.00" onclick="setPerepherals()" >Tablet ($60.00)</input> </td> </tr> <tr> <td align="center"><hr width="500" align="center" /></td> </tr> <tr> <td colspan="1" align="center"> Shipping: <input type="radio" align="middle" name="radShipping" value="5.00" onclick="setShipping()" >Ground ($5.00)</input> <br/><input type="radio" align="middle" name="radShipping" value="10.00" onclick="setShipping()" >Second Day Air ($10.00)</input> <br/><input type="radio" align="middle" name="radShipping" value="15.00" onclick="setShipping()" >Overnight Air ($15.00)</input> </td> </tr> <tr> <td align="center"><hr width="500" align="center" /></td> </tr> <tr> <td colspan="1" align="center"><input value="Calculate price" type="button" /></td> </tr> <tr> <td colspan="1" align="center"><textarea name="display" rows="10" cols="40">Total Price:</textarea></td> </tr> </table> *******For more information visit <a href="http://www.howstuffworks.com/pc.htm">How Computers Work.</a>******* </form> </center> </body> </html> I am very new to coding. The below is an assignment for a class. It is a "game" which is supposed to do the following: When your program starts up it must display the image that will move around, a Start button, a Stop button, and a way for the user to specify an interval before a new game begins. The default interval must be 1000 msec. When the user presses Start, a new game starts and the selected image is displayed at a random place. The image must move to a new random place once per interval. If the user presses the Stop button, the image must stop moving, and a subsequent Start must start everything over from the beginning. Each time the user successfully hits the image, the program must move the image to a new random place immediately (i.e., not wait for the current interval to end). When the user has hit the image 3 times, the program must display a confirm dialog box that reports the elapsed time and that also says something like "Another game?" If the user pushes OK, that starts a new game immediately (no need to push Start again). If Cancel is pushed, the program stops. I have been working on this for hours, but it does not work properly. Obvious issues: the game starts running when the page loads, instead of when the start button is pushed. The confirm at the end does not cause a new game to start. The time/ elapsed time calculations are not functioning properly/ the elapsed time always displays as 1 sec. Code: <html> <title> Dori's WhaM Game </title> <head> Stephen Salutes You </head> <body> <br> <img id="Colbert" src="StephenColbert.jpeg" style="position:absolute; left:10px; top:85px" onClick='hit()'> <form> <input type=button value="Start game." onClick='newgame()'> <input type=button value="Stop it, stop it now." onClick='clearInterval(setint_val); return true;'> <br> Desired speed is <input type=text id=interval value="1000" size=5> msec </form> <script> var hitcount= 0 var setint_val = (setInterval('moveit()', document.getElementById("interval").value)); var starttime var endtime function newgame() { clearInterval(setint_val) hitcount= 0 setInterval() starttime=new Date().getTime() } function moveit() { document.getElementById("Colbert").style.left = 800 * Math.random() + "px"; document.getElementById("Colbert").style.top = 500 * Math.random() + "px"; } function hit() { moveit() clearInterval(setint_val) setInterval() hitcount= hitcount + 1 if (hitcount >= 3) { clearInterval (setint_val); // clearInterval() to stop the image from moving endtime=new Date().getTime(); alert(starttime) alert (endtime) // compute the elapsed time (make another call to new Date()) if (confirm("That took " + endtime-starttime+" seconds. Would you like to try again?")) { newgame ()} else {clearInterval (setint_val) hitcount=0} }} </script> </body> </html> I have an homework for a web development class. I wrote a program that would be displayed on a webpage that returns the users zodiac sign. It was working just fine until i made small mistake somewhere but i just can't find it. If anyone could help I would appreciate it, I imagine it would be a very easy job for anyone familiar with javascript. [CODE] function signs() { var date=document.zodiac.date.value; var month=document.zodiac.month.selectedIndex; var fortune= new Array() fortune[0]="There is a true and sincere friendship between you and your friends. " fortune[1]="You find beauty in ordinary things, do not lose this ability. " fortune[2]="Ideas are like children; there are none so wonderful as your own. " fortune[3]="It takes more than good memory to have good memories. " fortune[4]="A thrilling time is in your immediate future. " fortune[5]="Your blessing is no more than being safe and sound for the whole lifetime. " if (document.zodiac.month.value == 1 && document.zodiac.date.value >=20 || document.zodiac.month.value == 2 && document.zodiac.date.value <=18) {document.zodiac.sign.value = "Aquarius";} if (document.zodiac.month.value == 1 && document.zodiac.date.value > 31) {document.zodiac.sign.value = "Invalid Date";} if (document.zodiac.month.value == 2 && document.zodiac.date.value >=19 || document.zodiac.month.value == 3 && document.zodiac.date.value <=20) {document.zodiac.sign.value = "Pisces";} if (document.zodiac.month.value == 2 && document.zodiac.date.value > 29) {document.zodiac.sign.value = "Invalid Date?";} if (document.zodiac.month.value == 3 && document.zodiac.date.value >=21 || document.zodiac.month.value == 4 && document.zodiac.date.value <=19) {document.zodiac.sign.value = "Aries";} if (document.zodiac.month.value == 3 && document.zodiac.date.value > 31) {document.zodiac.sign.value = "Invalid Date";} if (document.zodiac.month.value == 4 && document.zodiac.date.value >=20 || document.zodiac.month.value == 5 && document.zodiac.date.value <=20) {document.zodiac.sign.value = "Taurus";} if (document.zodiac.month.value == 4 && document.zodiac.date.value > 30) {document.zodiac.sign.value = "Invalid Date";} if (document.zodiac.month.value == 5 && document.zodiac.date.value >=21 || document.zodiac.month.value == 6 && document.zodiac.date.value <=21) {document.zodiac.sign.value = "Gemini";} if (document.zodiac.month.value == 5 && document.zodiac.date.value > 31) {document.zodiac.sign.value = "Invalid Date";} if (document.zodiac.month.value == 6 && document.zodiac.date.value >=22 || document.zodiac.month.value == 7 && document.zodiac.date.value <=22) {document.zodiac.sign.value = "Cancer";} if (document.zodiac.month.value == 6 && document.zodiac.date.value > 30) {document.zodiac.sign.value = "Invalid Date";} if (document.zodiac.month.value == 7 && document.zodiac.date.value >=23 || document.zodiac.month.value == 8 && document.zodiac.date.value <=22) {document.zodiac.sign.value = "Leo";} if (document.zodiac.month.value == 7 && document.zodiac.date.value > 31) {document.zodiac.sign.value = "Invalid Date";} if (document.zodiac.month.value == 8 && document.zodiac.date.value >=23 || document.zodiac.month.value == 9 && document.zodiac.date.value <=22) {document.zodiac.sign.value = "Virgo";} if (document.zodiac.month.value == 8 && document.zodiac.date.value > 31) {document.zodiac.sign.value = "Invalid Date";} if (document.zodiac.month.value == 9 && document.zodiac.date.value >=23 || document.zodiac.month.value == 10 && document.zodiac.date.value <=22) {document.zodiac..sign.value = "Libra";} if (document.zodiac.month.value == 9 && document.zodiac.date.value > 30) {document.zodiac.sign.value = "Invalid Date";} if (document.zodiac.month.value == 10 && document.zodiac.date.value >=23 || document.zodiac.month.value == 11 && document.zodiac.date.value <=21) {document.zodiac.sign.value = "Scorpio";} if (document.zodiac.month.value == 10 && document.zodiac.date.value > 31) {document.zodiac.sign.value = "Invalid Date";} if (document.zodiac.month.value == 11 && document.zodiac.date.value >=22 || document.zodiac.month.value == 12 && document.zodiac.date.value <=21) {document.zodiac.sign.value = "Sagittarius";} if (document.zodiac.month.value == 11 && document.zodiac.date.value > 30) {document.zodiac.sign.value = "Invalid Date";} if (document.zodiac.month.value == 12 && document.zodiac.date.value >=22 || document.zodiac.month.value == 1 && document.zodiac.date.value <=19) {document.zodiac.sign.value = "Capricorn";} if (document.zodiac.month.value == 12 && document.zodiac.date.value > 31) {document.zodiac.sign.value = "Invalid Date";} document.getElementById("image").src=document.zodiac.sign.value+".jpg" var randomFortune= Math.floor(Math.random() * 5) document.zodiac.fortunebox.value=fortune[randomFortune] document.getElementById('body').style.backgroundColor='#99FFCC' document.getElementById('body').style.backgroundColor='#99FFCC' document.tags.H1.color = '#99FFCC' } [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> <div style="background-color:#000000; height:60px;" > <h1 align="center"> What Zodiac Sign Are You? </h1> </div> <title>Horoscope Fortune Teller</title> <LINK REL=StyleSheet HREF="horoscope.css" TYPE="text/css" MEDIA=screen> <script type="text/javascript" src="Horoscope.js"> </script> </head> <body id=body> <br> <br> <table border=10px; align="center", height="250px"> <form name="zodiac"> <tr><td>Please select your day and month of birth to get started:</td></tr> <br> <br> <tr> <td>Choose month from the list:</td> <td> <select name="month"> <option value="1">January</option> <option value="2">February</option> <option value="3">March</option> <option value="4">April</option> <option value="5">May</option> <option value="6">June</option> <option value="7">July</option> <option value="8">August</option> <option value="9">September</option> <option value="10">October</option> <option value="11">November</option> <option value="12">December</option> </select> </td> </tr> <tr> <td>Enter day of birth:</td> <td><input type="text" name="date" value="Day" onClick=value=""></td> </tr> <tr> <td>Your Zodiac Sign is:</td><td><input type="text" name="sign" value="Zodiac Sign"></td> </tr> <tr> <td><input type="button" value="Click to find your sign" onClick="signs()"></td> <tr><td><img src="" id="image" alt="" /></td><td align="center"><input type="text" name="fortunebox" value="" size="80"></td></tr> </tr> </table> </form> <br> <br> <br> <br> <div style="background-color:#000000; height:60px;"></div> </body> </html> i am new in programming and learning it from lynda but i am trying to make a program which according to me is good enough but its not working and i am using free javascript editor for compiling and coding <!DOCTYPE html> <html> <body> <script> var a = 5; var b = 10; var c = 30; var d = a + b + c; alert("the value of d is" + d); </body> </html> Please tell me where is it i am making mistake Reply With Quote 01-08-2015, 11:56 PM #2 Old Pedant View Profile View Forum Posts Supreme Master coder! Join Date Feb 2009 Posts 28,311 Thanks 82 Thanked 4,754 Times in 4,716 Posts You forgot the </script> ending tag. Hi gud mng, I have one problem... How to process textbox values/ call textbox values in JS through a Java program. My text box values are dates. I have to process these dates. Like in online banking we select day to know our transactions. After submitting we get results. remember my files are in my directory only. No need of database. My files are look like 20100929, 20100930, 20101001 For epoch_classes.js, epoch_styles.css u can download coding from this link : http://www.javascriptkit.com/script/...ch/index.shtml Code: Code: <html> <table width="900" border="0" cellpadding="10" cellspacing="10" style="padding:0"> <tr><td id="leftcolumn" width="170" align="left" valign="top"> <div style="margin-left:0px;margin-top:0px"><h3 class="left"><span class="left_h2">Select Option</span></h3> <a rel="nofollow" target="_top" href="day_wise.htm" >Day-wise</a><br /> <br /> <a rel="nofollow" target="_top" href="between.htm" >Between Days</a> <link rel="stylesheet" type="text/css" href="epoch_styles.css" /> <script type="text/javascript" src="epoch_classes.js"></script> <script type="text/javascript"> var cal1, cal2; window.onload = function () { cal1= new Epoch('epoch_popup','popup',document.getElementById('popup_container1')); cal2= new Epoch('epoch_popup','popup',document.getElementById('popup_container2')); }; /*............*/ function confirmation(f) { var startdate = f.fromdate.value var enddate = f.todate.value var myday=new Date() var yr=myday.getFullYear() var mn=myday.getMonth()+1 var dt=myday.getDate() var today="" var present, ys, ms, ds, ye,me,de, start, end if(mn < 10) { mn = "0" + mn } if(dt <10) { dt = "0" + dt } today= yr + "/" + mn + "/" + dt present=yr + "/" + mn + "/" +dt if (today < startdate ) { alert (" Start date should not be exceed to-day's date " + present ) startdate.focus() return false } if (today < enddate ) { alert (" End date should not be exceed to-day's date " + present ) enddate.focus() return false } if (today == startdate ) { alert(" You are selected to-days date as Starting day" ); } var answer = confirm("Do you want to continue ?") if (answer) { if( startdate < enddate) alert("Dates between " + startdate + " to " + enddate + " are confirmed" ) else alert("Dates between " + enddate + " to " + startdate + " are confirmed" ) } else { alert("Date not confirmed") window.location="to_date.htm"; } ys= startdate.substring(0,4); ms= startdate.substring(5,7); ds= startdate.substring(8,10); start=ys + "" + ms + "" +ds ye= enddate.substring(0,4); me= enddate.substring(5,7); de= enddate.substring(8,10); end=ye + "" + me + "" +de } /*.......................................................*/ </script> <div style="margin-left:100px;"> <body> <style type="text/css"> #conf { margin-left:115px; } </style> <td align="left" valign="top"> <table width="100" border="0" cellpadding="0" cellspacing="0"> <td style="padding-top:0px"> </table> <h4>From Date</h4> <form name= "formbet" id="placeholder" method="post" action="#" > <input id="popup_container1" type="text" name= "fromdate" maxlength="10" size="20"/> <td align="left" valign="top"> <table width="300" border="0" cellpadding="0" cellspacing="0"> <td style="padding-top:20px"> <h4>To Date</h4> <input id="popup_container2" type="text" name= "todate" maxlength="10" size="20"/> <br /> <br /> <input id="conf" type="button" onclick="confirmation(this.form)" value="Submit"> </form> </body> </html> In my coding, ys, ms, ds represents year starting, month starting, starting day... ye, me, de represents end... start,end gives file names in the format of yyyymmdd now i want to process files from 20100101 to 20100930 means from date is 2010/01/01 and to date is 2010/09/30 if i press submit button the files from 20100101 to 20100930 are processes here ys=2010 ms=01 ds =01 and ye=2010 me=09 de= 30 For this how do i call these textbox values (from date text box and todate) to another program (java) Thanks in advance. 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> Hey, so I have successfully used this tutorial; http://articles.sitepoint.com/articl...y-javascript/3 to create a web page that "smoothscrolls" down to a certain point of content on the page. So, I know the java works! My problem is, I have changed the website to be along the X axes and not the Y, so instead of it scrolling "down" the page, I would like it to scroll from left to right. i.e on the X axes not the Y. Is there anyway of doing this by editing that java file? All my buttons work and display the correct part of the website, but the java doesn't work slidiing sideways. Thank you in advance! Darren Can Someone please help me with the script for making this work. This is a assignment I am having trouble with the required codes bring up a discount box displaying the output details dependent on the discount code used. I Belleive the While operator is used for this can someone please help me?I no my codes are probably all wrong but am desperate for help thanks For this part of the question you can assume that the user always inputs one of the three correct codes, FSSAVE, ISSAVE and SOSAVE. If (Discount code entered is FSSAVE) give discount one else if (discount code entered is ISSAVE) give discount 2 else if (discount code entered is SOSAVE) give discount 3 var discount; fSSAVE; iSSAVE; sOSAVE fSSAVE = 20p iSSAVE = 30p sOSAVE = 40p discount = window.prompt('Please enter a discount code,' Here'); I need some help with some simple coding. I'm editing a website of parameters at work and I have two text boxes that are beside each other. The second text box has a label that shows with it. The second text box and label doesn't need to show unless the first text box has something keyed into it. Could somebody help me with this javascript? showing already:::::::::::::::: dont show until txtbox1 is typed txtbox1 ::::::::::::::::::::::::: lbltxtbox2 : txtbox2 Any help would be greatly appreciated. Thanks Hello, I am trying to create simple Java Script form that will open a URL based on the contents entered into the form. The form shall consist of only a text box and submit button. A user will enter XXXX in the text box and click submit. The form would then load a URL consisting of http://www.company.com/XXXX I know this can be done because I had a code like this a few years back but I have lost it. I've been searching for over an hour, trying to figure this out. Any help would be grately appreciated. Thanks! Hello all, As I am new to java scripts, I usually solve thing with trial and error. What I need is a very simple java script for a count down timer, after searching here I found this: ---------------------- Code: <font style="font-size:72px" color="#FF0000" face="Arial"> <script type = "text/javascript"> var page = "http://www.google.com"; //The page to redirect to function getSeconds() { startTimer (3); // 36 hours } var timeInSecs; var ticker; function startTimer(secs){ timeInSecs = parseInt(secs); ticker = setInterval("tick()",1000); tick(); // to start counter display right away } function tick() { var secs = timeInSecs; if (secs>0) { timeInSecs--; } else { window.location = page; // stop counting at zero // and start again if required } var hours= Math.floor(secs/3600); secs %= 3600; var mins = Math.floor(secs/60); secs %= 60; var result = ( (mins < 10) ? "0" : "" ) + mins + ":" + ( (secs < 10) ? "0" : "" ) + secs; document.getElementById("countdown").innerHTML = result; } </script> <body onload = "getSeconds()"> <span id="countdown" style="font-weight: bold;" ></span> ----------------------------- I modified some stuff, as I defined the font face and size, the color as well, and I added a var to open a certain page when the time is over (as I said before, all these modifications came right with trial and error). So, is that script good? or are there better scripts that do the same job? And, can someone please provide me with a script that does the same functionality of the script I mentioned but instead of showing digits it shows: 01 minutes 31 seconds ? Thank you so much. I need a count down clock that will count down 18 minutes and reset itself at the end. also i need a counter that increases by +1 every 18 minutes starting at 0. thankyou |