JavaScript - Golf Stableford Counter Using Mod Stableford!?!?
I have this stableford point counter which works perfect, but... I also wants to make one for modyfied stableford...
A little explanation is in order. Stableford is a point system for golfers depending on how good they are and how difficult a course is. So a par4 hole should if you are Tiger Woods be played in 4 strokes, and that would give him 2 points, but... A player can be awarded extra strokes to a hole depending on there handicap, so if a player has been awarded 1 extra hole, this players par would be 5 and that would give him 2 points. If he uses 1 stroke less (4) he would get 3 points and so on, and if uses 1 stroke more (6) he would get 1 point and 2+ strokes more (7) he would get 0 point. For this I have this script: Code: function stableford_calc(){ var holes_par = new Array(<? echo $p1.",".$p2.",".$p3.",".$p4.",".$p5.",".$p6.",".$p7.",".$p8.",".$p9.",".$p10.",".$p11.",".$p12.",".$p13.",".$p14.",".$p15.",".$p16.",".$p17.",".$p18; ?>); // Par // var holes_si = new Array(<? echo $h1.",".$h2.",".$h3.",".$h4.",".$h5.",".$h6.",".$h7.",".$h8.",".$h9.",".$h10.",".$h11.",".$h12.",".$h13.",".$h14.",".$h15.",".$h16.",".$h17.",".$h18; ?>); // HCP Key // var hcap = validNum(document.form2.strokecount.value); // Number of extra strokes // for (i=0; i<=17; i++) { var shots = validNum(document.form2["stroke"+i].value); // Actual strokes // var par = holes_par[i]; var si = holes_si[i]; var maxallow = 0; if (hcap < 0) { var diff = hcap + 18; maxallow = (diff >= si) ? 0 : -1; } else if (hcap > 72) { var diff = hcap - 72; maxallow = (diff >= si) ? 5 : 4; } else if (hcap > 54) { var diff = hcap - 54; maxallow = (diff >= si) ? 4 : 3; } else if (hcap > 36) { var diff = hcap - 36; maxallow = (diff >= si) ? 3 : 2; } else if (hcap > 18) { var diff = hcap - 18; maxallow = (diff >= si) ? 2 : 1; } else { maxallow = (hcap >= si) ? 1 : 0; } var score = shots - maxallow; var points = (par - score) + 2; if (points < 0) points = 0; if ((document.form2["stroke"+i].value== "") || (document.form2["stroke"+i].value== 0)) { document.form2["p"+i].value="0"; } else { document.form2["p"+i].value = points; } /*if (document.form2["stroke"+i].value===''){ document.form2["p"+i].value="0" } else { document.form2["p"+i].value = points; }*/ } var i,a=[]; for (i=0; i<=17; i++){ a[i]=validNum(document.form2["p"+i].value); } var st_out = a[0] + a[1] + a[2] + a[3] + a[4] + a[5] + a[6] + a[7] + a[8]; var st_in = a[9] + a[10] + a[11] + a[12] + a[13]+ a[14] + a[15] + a[16] + a[17]; document.form2.p_out.value = st_out; document.form2.p_in.value = st_in; document.form2.p_total.value = st_out + st_in; } Now, in modyfied stableford its a bit different. If a player uses his awarded amount of strokes + the holes par he would get 0 point. If he uses a stroke less (birdie) he would get 2 point. 2 strokes less (eagle) 5 points and 3+ strokes less (albatros) 8 points. If he uses 1 stroke more (bogey) he would get -1 point and 2+ strokes more -3 point... I would think that I could reuse the most of the above script, but not sure how to get the points in the right place... Hope this makes some sense, and apreciates any kind of help... Similar TutorialsHi, I'm very new to programming, and for practice I tried to build a program that calculates a golfer's handicap based on the course they played and their score on each hole. The program is designed to cap a golfer's score at 2 over par. For some reason, the program works when the hole scores are at least 2 over par, but not any other time. Would someone mind taking a look at the code below and letting me know where I went wrong? I appreciate the help! Code: //Program designed to calculate golf handicap //based on couse and scores on every hole. var course = prompt("What Course?"); if (course === "Seneca"){ var AB = prompt("Course A or B"); if (AB === "A" || AB === "a"){ var rating = 35.45; var slope = 56.5; var side = prompt("Front or Back"); if (side === "Front" || side === "front"){ var par1 = 4; var par2 = 4; var par3 = 5; var par4 = 3; var par5 = 4; var par6 = 4; var par7 = 4; var par8 = 5; var par9 = 3;} else { var par1 = 4; var par2 = 4; var par3 = 4; var par4 = 3; var par5 = 4; var par6 = 4; var par7 = 5; var par8 = 3; var par9 = 4;} } else { var rating = 35.8; var slope = 57; var side = prompt("Front or Back"); if (side === "Front" || side === "front"){ var par1 = 4; var par2 = 4; var par3 = 5; var par4 = 3; var par5 = 4; var par6 = 4; var par7 = 4; var par8 = 4; var par9 = 4;} else { var par1 = 4; var par2 = 3; var par3 = 5; var par4 = 4; var par5 = 3; var par6 = 4; var par7 = 4; var par8 = 4; var par9 = 4;} } } else { alert("Check Spelling");} //Asking for scores by hole. var hole1 = prompt("Hole 1 score?"); var hole2 = prompt("Hole 2 score?"); var hole3 = prompt("Hole 3 score?"); var hole4 = prompt("Hole 4 score?"); var hole5 = prompt("Hole 5 score?"); var hole6 = prompt("Hole 6 score?"); var hole7 = prompt("Hole 7 score?"); var hole8 = prompt("Hole 8 score?"); var hole9 = prompt("Hole 9 score?"); //Capping hole scores at two over par. if (hole1 >= par1 + 2){ var handiScore1 = par1 + 2;} else {var handiScore1 = hole1;} if (hole2 >= par2 + 2){ var handiScore2 = par2 + 2;} else {var handiScore2 = hole2;} if (hole3 >= par3 + 2){ var handiScore3 = par3 + 2;} else {var handiScore3 = hole3;} if (hole4 >= par4 + 2){ var handiScore4 = par4 + 2;} else {var handiScore4 = hole4;} if (hole5 >= par5 + 2){ var handiScore5 = par5 + 2;} else {var handiScore5 = hole5;} if (hole6 >= par6 + 2){ var handiScore6 = par6 + 2;} else {var handiScore6 = hole6;} if (hole7 >= par7 + 2){ var handiScore7 = par7 + 2;} else {var handiScore7 = hole7;} if (hole8 >= par8 + 2){ var handiScore8 = par8 + 2;} else {var handiScore8 = hole8;} if (hole9 >= par9 + 2){ var handiScore9 = par9 + 2;} else {var handiScore9 = hole9;} //Testing to make sure hole scores come through OK console.log(hole1, hole2, hole3, hole4, hole5, hole6, hole7, hole8, hole9); console.log(par1, par2, par3, par4, par5, par6, par7, par8, par9); console.log(handiScore1, handiScore2, handiScore3, handiScore4, handiScore5, handiScore6, handiScore7, handiScore8, handiScore9); //Calculating total score var score = [handiScore1, handiScore2, handiScore3, handiScore4, handiScore5, handiScore6, handiScore7, handiScore8, handiScore9]; var total = 0; for (var i=0; i < score.length; i++){ total += score[i];} //Calculating handicap var a = (total - rating); var b = (a * 56.5); var c = (b / slope); console.log(c); The golf ball is supposedly to come out and bounce across the screen and land in the word golf. Code: <html> <head> <!-- New Perspectives on JavaScript Tutorial 4 Case Problem 1 The Golf Page Author: Cheryl Ashworth Date: July 12, 2010 Filename: golfpage.htm Supporting files: ball.gif, clouds.jpg, golf.js, golfer.gif, styles.css --> <title>The Golf Page</title> <link href="styles.css" rel="stylesheet" type="text/css" /> <script src="golf.js" type="text/javascript"></script> <script type="text/javascript"> var x = new Array(-395, -389, -383, -377, -371, -365, -359, -353, -346, -340, -334, -328, -322, -316, -310, -304, -297, -291, -285, -279, -273, -267, -261, -255, -248, -242, -236, -230, -224, -218, -212, -206, -199, -193, -187, -181, -175, -169, -163, -157, -150, -144, -138, -132, -126, -120, -114, -108, -101, -95, -93, -91, -88, -86, -83, -81, -78, -76, -73, -71, -69, -66, -64, -61, -59, -56, -54, -51, -49, -47, -44, -42, -39, -37, -34, -32, -29, -27, -24, -22, -20, -17, -15, -12, -10, -7, -5, -2, 0); var y = new Array(-300, -300, -300, -299, -298, -297, -296, -294, -292, -290, -288, -285, -282, -279, -276, -272, -268, -264, -260, -255, -250, -245, -240, -234, -228, -222, -216, -209, -202, -195, -188, -180, -172, -164, -156, -147, -138, -129, -120, -110, -100, -90, -80, -69, -58, -47, -36, -24, -12, 0, -5, -10, -14, -18, -22, -25, -29, -32, -34, -37, -39, -41, -43, -45, -46, -47, -48, -48, -48, -48, -48, -48, -47, -46, -45, -43, -42, -40, -37, -35, -32, -29, -26, -23, -19, -15, -11, -6, 0); var index=0; function moveBall() { if (index<=x.length-1) <!-- length check --> { placeIt("Ball", x[index], y[index]); index++; setTimeout("moveBall()",5) } else { showIt("Slogan"); } </script> <!-- External Javascripts --> <script src="Golf.js"></script> </HEAD> <!-- Body --> <BODY onLoad="moveBall()"> <!-- Title --> <DIV ID="Title" STYLE="padding-left:395;padding-top:260;padding-bottom:0; border-style:solid; border-width:1 3 3 1; border-color:blue; background-color:rgb(0,255,0)"> THE G<SPAN ID="Ball"STYLE="position:relative;left:0;top:0"><IMG SRC="Ball.gif" BORDER=0></SPAN>LF PAGE </DIV> <!-- Slogans --> <DIV ID="Slogan" STYLE="color:black; font-family: Times New Roman, Times, serif; font-style:italic; font-weight:bold; position:absolute; left:120; top:100; z-index:2;visibility:hidden"> Your Online Source of Golf Equipment </DIV> <DIV ID="Slogan2" STYLE="color:white; font-family: Times New Roman, Times, serif; font-style:italic; font-weight:bold; position:absolute; left:121; top:101; z-index:1;visibility:hidden"> Your Online Source of Golf Equipment </DIV> <!-- End --> </BODY> </HTML> */ JS Script Code: Function List: placeIt(id, x, y) Places the id object at the coordinates (x, y) showIt(id) Shows the id object by setting the object visibility to "visible" getFontSize(id) Retrieves the font size of the id object setFontSize(id, fs) Sets the font size of the id object to fs changeFontSize(id, dfs) Changes the font size of the id object by dfs */ function placeIt(id, x, y) { // Places the id object at the coordinates (x,y) object=document.getElementById(id); object.style.left=x+"px"; object.style.top=y+"px"; } function getFontSize(id) { // Returns the font size of the object with the value id object=document.getElementById(id); size=parseInt(object.style.fontSize); return(size); } function setFontSize(id, ptsize) { // Sets the font size of the object with the value id object=document.getElementById(id); object.style.fontSize = ptsize + "pt"; } function changeFontSize(id, dfs) { // Returns the font size of the object with the value id fs = getFontSize(id); setFontSize(id, fs+dfs); }CSS */ Code: This file contains styles used in the golfpage.htm file Code: body {font-family:Arial, Helvetica, sans-serif; font-size: 18pt; color:blue; background-image: url(clouds.jpg)} #Title {position: absolute; left:395px; top:260px} #Ball {position:relative; top:0px; left:0px} #Ball img {border-width: 0px} #box {width:600px; height: 250px; border-style:solid; border-width:1 4 4 1; border-color:blue; background-color:rgb(0,255,0); text-align: center} #slogan {visibility: hidden; position: relative; top: 50px; color:black; font-family: Times New Roman, Times, serif; font-style:italic; font-weight:bold} */ I almost got part of this one program to work. It is of a golf sign with a golf ball moving across and landing in the word Golf into the "o" When the ball lands in the o the sign of "your online source of golf equipment" appears after ball has landed and grows in size. right now the ball is what I have but I can not get my sign to appear. I use 2 external files I will post all the coding here here is my main file I worked on this is my golfpage.htm file Code: <html> <head> <!-- New Perspectives on JavaScript Tutorial 4 Case Problem 1 The Golf Page Author: Date: 05 December 2010 Filename: golfpage.htm Supporting files: ball.gif, clouds.jpg, golf.js, golfer.gif, styles.css --> <title>The Golf Page</title> <link href="styles.css" rel="stylesheet" type="text/css" /> <script src="golf.js" type="text/javascript"></script> <script type="text/javascript"> var x = new Array(-395, -389, -383, -377, -371, -365, -359, -353, -346, -340, -334, -328, -322, -316, -310, -304, -297, -291, -285, -279, -273, -267, -261, -255, -248, -242, -236, -230, -224, -218, -212, -206, -199, -193, -187, -181, -175, -169, -163, -157, -150, -144, -138, -132, -126, -120, -114, -108, -101, -95, -93, -91, -88, -86, -83, -81, -78, -76, -73, -71, -69, -66, -64, -61, -59, -56, -54, -51, -49, -47, -44, -42, -39, -37, -34, -32, -29, -27, -24, -22, -20, -17, -15, -12, -10, -7, -5, -2, 0); var y = new Array(-300, -300, -300, -299, -298, -297, -296, -294, -292, -290, -288, -285, -282, -279, -276, -272, -268, -264, -260, -255, -250, -245, -240, -234, -228, -222, -216, -209, -202, -195, -188, -180, -172, -164, -156, -147, -138, -129, -120, -110, -100, -90, -80, -69, -58, -47, -36, -24, -12, 0, -5, -10, -14, -18, -22, -25, -29, -32, -34, -37, -39, -41, -43, -45, -46, -47, -48, -48, -48, -48, -48, -48, -47, -46, -45, -43, -42, -40, -37, -35, -32, -29, -26, -23, -19, -15, -11, -6, 0); var index=0; var lastindex=x.length-1; // var fs=getFontSize("slogan"); function moveBall() { if (index <= lastindex) { placeIt("Ball", x[index], y[index]); index++; setTimeout("moveBall()", 5); } else { setFontSize("slogan", 25); } } </script> </head> <body onload="moveBall()"> <div id="Golfer" ><img src="golfer.gif" width="40px" alt="" /></div> <div id="Title"> THE G<div style="display: inline; position: relative; background-color: black;" ><img id="Ball" src="ball.gif" alt="O" /></div>LF PAGE </div> <div id="box" style=""> <span id="slogan"> Your Online Source of Golf Equipment </span> </div> </body> </html> Here is one external file where I made some functions this is the golf.js file Code: New Perspectives on JavaScript Tutorial 4 Case Problem 1 The Golf Page Name: Date: 05 december 2010 Function List: placeIt(id, x, y) Places the id object at the coordinates (x, y) showIt(id) Shows the id object by setting the object visibility to "visible" getFontSize(id) Retrieves the font size of the id object setFontSize(id, fs) Sets the font size of the id object to fs changeFontSize(id, dfs) Changes the font size of the id object by dfs */ function showIt(id) { object=document.getElementById(id); object.style.visibility="visible"; } function placeIt(id, x, y) { // Places the id object at the coordinates (x,y) object = document.getElementById(id); object.style.left = x + "px"; object.style.top = y + "px"; } function getFontSize(id) { // Returns the font size of the object with the value id object = document.getElementById(id); size = parseInt(object.style.fontSize); return (size); } function setFontSize(id, ptsize) { // Sets the font size of the object with the value id object = document.getElementById(id); object.style.fontSize = ptsize + "pt"; } function changeFontSize(id, dfs) { // Returns the font size of the object with the value id fs = getFontSize(id); setFontSize(id, fs + dfs); } Here is the styles.css page Code: /* New Perspectives on JavaScript Tutorial 4 Case Problem 1 Filename: styles.css This file contains styles used in the golfpage.htm file */ body {font-family:Arial, Helvetica, sans-serif; font-size: 18pt; color:blue; background-image: url(clouds.jpg)} #Title {position: absolute; left:395px; top:260px} #Ball {position:relative; top:0px; left:0px} #Ball img {border-width: 0px} #box {width:600px; height: 250px; border-style:solid; border-width:1 4 4 1; border-color:blue; background-color:rgb(0,255,0); text-align: center} #slogan {visibility: hidden; position: relative; top: 50px; color:black; font-family: Times New Roman, Times, serif; font-style:italic; font-weight:bold} What i am not able to get work i think is to call the changeFontSize() function to increase the size of the "sign" also an if statement to test value of fs variable is less then equal to 20 how do i get my sign to appear on the output? thanks Hey Everyone, I'm working on a counter. I have two images - each with their own click count. Right now each time the page loads the counter goes back to zero. I would assume I need some kind of server side coding. Any recommendations? Here's what I have so far. <html> <head> <script type="text/javascript"> var counter = 0; function increaseloveit() { counter += 1; document.getElementById('loveit').value = counter; } var counter = 0; function increasehateit() { counter += 1; document.getElementById('hateit').value = counter; } </script> </head> <body> <form> <a href="#" onclick="javascript:increaseloveit();"><input type="button" value="Love It!" name="loveit" onclick="" /></a><input id="loveit" value="0" size="2" /></form> <form> <a href="#" onclick="javascript:increasehateit();"><input type="button" value="Hate It!" name="hateit" onclick="" /></a><input id="hateit" value="0" size="2" /></form> </body> </html> So I'm really new to javascript and html. The most advanced thing Ive made was probably a Russian rullete simulator, but I need help with this one program Im working on. So if anyone could tell me whats wrong with this, I would appreciate it! <html> <head> <font size="4">Click the button below as many times as you can</font> <br> <script type="text/javascript"> var clicks=0 function count() { clicks=clicks+1; } </script> </head> <body> <input type="button" value="Click Me" OnClick="count()"> <br> <p>Clicks: <script type="text/javascript"> document.write(clicks); </script></p> </body> </html> I have the following codes and it seems to work well but when exiting the site and re-entering it resets the values to 0 again. I am not sure how to proceed with this, been considering cookies but what if the user clears there cookies, I then looked at PHP but not understanding that to well at this stage. Javascript Code: // Function to count clicks on links var clicks1 = 0; var clicks2 = 0; var clicks3 = 0; var clicks4 = 0; function link1(){ document.getElementById('clicked1').value = ++clicks1; } function link2(){ document.getElementById('clicked2').value = ++clicks2; } function link3(){ document.getElementById('clicked3').value = ++clicks3; } function link4(){ document.getElementById('clicked4').value = ++clicks4; } HTML Code: Code: <tr valign="middle" align="center"><td colspan="1"><a target="_blank" href="http://mistiquestormelectronics.webs.com/" onclick="link1()"><img src="site_graphics/reinet.jpg" alt="Mistique Storm" width="120" height="90" /></a></td> <td colspan="2" align="left"><p>For all your Electronic equipment needs.</p></td> <td colspan="1" width="8%"><input id="clicked1" style="color: #000000; font-weight:bold; border-style: none; font-family: arial; background-color: #00FF00; text-align: center;" readonly="readonly" size="10" onfocus="this.blur();" value="0" ></td></tr> Any ideas, suggestions. Please Help? I need help with a counter that will either display a different image everyweek or change text every week. The scenario is a counter will be on the top right corner of the page, and every week the number will change from 1 to 2 to 3... to 52... I searched on this forum for answers, i found some similar for a different day counter. Any help would be great! Hi All, could you please help me. A have a little program and i need to count somehow how many times a while loop is ran. how could i do that? Thanks for your help I am trying to use the Jquery loader (this ends when page loads) but I want it to load how many seconds the page took. (using the clean preloader) $( "#progressbar" ).progressbar({ value: setTimeout("seconds++",10000000) }); but getting "anything" to work in the "VALUE" has been such a pain. any one that knows how to create a timer to add to the value so that preload will keep loading? or if even possible? thanks Hi, I have added a time counter in below code. This is used to track the total time of a project. If a person is going on break, then they will apply the break that stops the time counter. However, once they come back from break and end the break, then time is counting at double speed (two seconds instead at one second). Is there any mistake that I done that made the time counter to increment by 2 seconds instead of 1 second after break. Any help please.... Code: <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" /> <title>Strategy One - Tracker</title> <link rel="stylesheet" href="style.css" type="text/css" media="screen" /> <!--[if IE 6]><link rel="stylesheet" href="style.ie6.css" type="text/css" media="screen" /><![endif]--> <!--[if IE 7]><link rel="stylesheet" href="style.ie7.css" type="text/css" media="screen" /><![endif]--> <!-- Script for Current time in text box --> <script type="text/javascript"> function GetDate() { var curDateTime = new Date() var curHour = curDateTime.getHours() var curMin = curDateTime.getMinutes() if(curHour<10) curHour = "0" + curHour if(curMin<10) curMin = "0" + curMin document.getElementById('start_time').value = curHour + ":" + curMin; var row = document.getElementById("end1_time"); var row1 = document.getElementById("start1_time"); row.style.display = 'none'; row1.style.display = 'none'; } </script> <!-- End of Script for Current time in text box --> <!-- Script for Current time in text box --> <script type="text/javascript"> function GetDate1() { var curDateTime = new Date() var curHour = curDateTime.getHours() var curMin = curDateTime.getMinutes() if(curHour<10) curHour = "0" + curHour if(curMin<10) curMin = "0" + curMin document.getElementById('end_time').value = curHour + ":" + curMin; var row = document.getElementById("start1_time"); var row1 = document.getElementById("end1_time"); var row2 = document.getElementById("start2_time"); var row3 = document.getElementById("end2_time"); row.style.display = 'none'; row1.style.display = 'none'; row2.style.display = 'none'; row3.style.display = 'none'; } </script> <script type="text/javascript"> function GetDate2() { var curDateTime = new Date() var curHour = curDateTime.getHours() var curMin = curDateTime.getMinutes() if(curHour<10) curHour = "0" + curHour if(curMin<10) curMin = "0" + curMin document.getElementById('break_time_out').value = curHour + ":" + curMin ; var row = document.getElementById("end2_time"); row.style.display = ''; } </script> <script type="text/javascript"> function GetDate3() { var curDateTime = new Date() var curHour = curDateTime.getHours() var curMin = curDateTime.getMinutes() if(curHour<10) curHour = "0" + curHour if(curMin<10) curMin = "0" + curMin document.getElementById('break_time_in').value = curHour + ":" + curMin ; } </script> <script type="text/javascript"> function tout1() { var temp= document.tracker.start_time.value; if(temp.length>0) { var row1 = document.getElementById("end1_time"); var row2 = document.getElementById("start2_time"); row1.style.display = 'none'; row2.style.display = 'none'; } else { var row = document.getElementById("start1_time"); var row1 = document.getElementById("end1_time"); var row2 = document.getElementById("start2_time"); row.style.display = 'none'; row1.style.display = 'none'; row2.style.display = 'none'; } } function tout2() { var temp= document.tracker.start_time.value; if(temp.length>0) { var row = document.getElementById("start1_time"); var row1 = document.getElementById("end1_time"); var row2 = document.getElementById("start2_time"); var row3 = document.getElementById("end2_time"); row.style.display = 'none'; row1.style.display = 'none'; row2.style.display = 'none'; row3.style.display = 'none'; } else { var row = document.getElementById("start1_time"); var row1 = document.getElementById("end1_time"); var row2 = document.getElementById("start2_time"); var row3 = document.getElementById("end2_time"); row.style.display = ''; row1.style.display = 'none'; row2.style.display = 'none'; row3.style.display = 'none'; } } </script> <script type="text/javascript"> var seconds = 0; var minutes = 0; var hours = 0; function zeroPad(time) { var numZeropad = time + ''; while(numZeropad.length < 2) { numZeropad = "0" + numZeropad; } return numZeropad; } function countSecs() { var j=document.tracker.hide.value; if(j=="yes") { seconds++; if (seconds > 59) { minutes++; seconds = 0; } if (minutes > 59) { hours++ minutes = 0; } document.tracker.time_utilization.value = zeroPad(hours) + ":" + zeroPad(minutes) + ":" + zeroPad(seconds); } else {} } function startTimer() { action = window.setInterval(countSecs,1000); } function s() { document.tracker.hide.value ="yes"; startTimer(); } function p() { document.tracker.hide.value ="no"; } </script> </head> <body> <form name="tracker" method="post" action="processor.php" onsubmit="return formCheck(this);"> <label class="formFieldQuestion">Start Time *</label><input readonly class=mainForm type=text name=start_time id=start_time size='30' value=''> <input type="button" id="start1_time" style="width: 100px" Value="Start Time" onClick="javascript:GetDate();s();"></li> <label class="formFieldQuestion">End Time *</label><input readonly class=mainForm type=text name=end_time id=end_time size='30' value='' > <input type="button" id="end1_time" style="width: 100px" Value="End Time" onClick="javascript:GetDate1(); p();" style='display: none'></li> <input type="hidden" name="hide" /> <label class="formFieldQuestion">Break Time Out </label><input class=mainForm readonly type=text name=break_time_out id=break_time_out size='30' value='' > <input type="button" id="start2_time" style="width: 100px" Value="Start Time" onClick="javascript:GetDate2();tout1();p();"></li> <label class="formFieldQuestion">Break Time In </label><input class=mainForm readonly type=text name=break_time_in id=break_time_in size='30' value=''> <input type="button" id="end2_time" style="width: 100px" Value="End Time" onClick="javascript:GetDate3(); tout2();s();" style='display: none'></li> <label class="formFieldQuestion">Time Utilization</label><input class=mainForm type=text name=time_utilization id=time_utilization size='30' value='' readonly></li> <br /> <br /> <input id="saveForm" class="mainForm" type="submit" value="Submit" style="width : 100px"/> </form> </body> </html> H, I'm trying to create an sms form. but I want the users to be able to monitor the characters and sms number as they type...taking 160 characters to be 1 page. pls I'll need help with coding this form to display characters left in 'ch_count' box and number of pages in the 'pages' box while typing in the 'message' textarea....hope it's clear enough...thanks Code: <p> <textarea name="message" cols="" rows="" id="message"></textarea> </p> <p> <input name="ch_count" type="text" id="ch_count" size="8" /> characters left <input name="pages" type="text" id="pages" size="8" /> pages </p> Anybody help to start out this code: Create a "nag" counter that tells users to register. Save the counter in a cookie and display a message reminding users to register every fifth time they visit your site. There are four other parts to this task that I know how to do. I cannot find anything close to this in our book referencing a nag-counter or something similar to it. Thanks, in advance. Regards, AO5431 Hi Guys, Hope you can help. My sister has made a web site with a web counter and want to get the counter up by a few hundered. She cannot alter the number manually. Is there a script i can use to get the web counter up by a few hundred? So in other words a web page with java on so it gones on to her site (adds a count) leave it Or refresh it then reload it. Hope i have made my self Clear. thanx, Or even i culd run a web page which loads the page, closes it and load it again. Thanx. Lusa.. Hey Everyone, I'm trying to set up two different buttons that count their own individual clicks. So far I have everything except where one button leaves off, the other picks up. So if I click the left one three times it shows the number 3, and then if I click the button next to it, that button picks up at 4. I want each button to have its own count. Any ideas? Here's what I have so far. <html> <head> <script type="text/javascript"> var counter = 0; function increaseloveit() { counter += 1; document.getElementById('loveit').value = counter; } var counter = 0; function increasehateit() { counter += 1; document.getElementById('hateit').value = counter; } </script> </head> <body> <form> <a href="#" onclick="javascript:increaseloveit();"><input type="button" value="Love It!" name="loveit" onclick="" /></a><input id="loveit" value="0" size="2" /></form> <form> <a href="#" onclick="javascript:increasehateit();"><input type="button" value="Hate It!" name="hateit" onclick="" /></a><input id="hateit" value="0" size="2" /></form> </body> </html> I have the following code but it is not even showing up in the browser. I am very new to JS and very willing to learn. The code was originally found on this site and I have tweaked it and now it doesn't work...Any assistance would be much appreciated. <script type = "text/javascript"> var seconds; var clockId; function startClock(seconds){ timeInSeconds = parseInt(seconds); clockId = setInterval("tick()",1000); } function runClock() { var seconds = timeInSeconds; if (seconds > 60) { // stop at "" seconds alert ("Your time is up!"); clearInterval(clockId); // stop counting return false; } else { timeInSecs++; } var hours= Math.floor(seconds/3600); seconds %= 3600; var mins = Math.floor(seconds/60); secs %= 60; var result = ((hours < 10 ) ? "0" : "" ) + hours + ":" + ( (mins < 10) ? "0" : "" ) + mins + ":" + ( (secondss < 10) ? "0" : "" ) + seconds; document.getElementById("countdown").innerHTML = result; } startClock(0); // start count at 0 seconds </script> <span id="countdown" style="font-weight: bold;"></span> I have 2 questons. 1) Is there a way for the loop counter to loop while less then [a php variable]? 2) Is there a way to use a counter in the name of the form elements? Example, instead of "switchBox1" use: "switchBoxCounter" instead of "nameaddy1" use: "nameaddyCounter" Code: if(document.form1.switchBox1.checked) { document.form1.nameaddy1.style.backgroundColor = "#E5E5E5"; } else { document.form1.nameaddy1.style.backgroundColor = "#FFFFFF"; } Hi, First i don know if im posting at the right place or if you even take request here, feel free to direct me to the right place. What i am looking for is someone to make a simple counter for me. Basically i want that every time i press a certain key on my keyboard it will increase the counter amount and would then divide it by 60 every hour. Actually im looking for it to only show that average and refresh every hour. So it would start at 0 then update after the first hour and so on. (I also need a graphical interface) I have very few knowledge in coding and would very appreciate if someone could do that for me. Thank you ! Reply With Quote 01-10-2015, 11:39 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 I don't think this is something you would do with JavaScript. I think you need a ".exe" (on Windows) program. And that's a lot more complex. The problem is your request to capture a certain key, presumably no matter what window is at the front. Normally, within a given window, you can only capture a key that is intended for that window. I don't think this is a very easy thing to do. hello, I have a textbox in my .net page, and totally new to java script. How do i get a script that will count the data being written in the text box to show increments of 100 and write the value to the bottom of the textbox. e.g. When u get to 100, at the bottom it says "1st hundred" ... and to 200 it writes "2nd hundred" UP to 500 ??? Please help thanks |