Hi guys I'm making a golf handicap calculator, you have a couple of columns, for each hole - par, score, difference and adjusted difference. I need to total up each column, and this is my code to do it. It works but feels inefficient and clunky. Any thoughts on improving it? In particular can you sum up a bunch of inputboxes with the same class instead of using the each loop? [CODE]function calcTotals() { var tpar = 0; var tscore = 0; $("#scorecard .par").each(function(){ if(isNumber($(this).val())) { tpar += parseInt($(this).val()); } if(isNumber($(this).parent("td").next("td").find("input").val())) { tscore += parseInt($(this).parent("td").next("td").find("input").val()); } }); $("#totPar").html(parseInt(tpar)); $("#totScore").html(parseInt(tscore)); } …

Member Avatar
+0 forum 0

Hi, I've got a "contact us" form on my website and naturally i'm trying to guard against sql injection/hacking The body of the text gets run through the below function, however this means i end up with How's it going = How's it going Can someone tell me which part of the function causes this and a work around? Thank you [CODE] function check_input($value) { if (get_magic_quotes_gpc()) { $value = trim(stripslashes($value)); } if (!is_numeric($value)) { $value = trim(stripslashes($value)); $value = mysql_real_escape_string($value); } return $value; } [/CODE]

Member Avatar
Member Avatar
+0 forum 2

Hi all, I dabble in a bit of XNA from time to time. I'm creating a 2d top down tank game. My AI bot that controls the enemy tank, works like this simple pathfinding to target until in range, turn turret to target and fire. The problem I have is, it's really hard to defeat the AI tank as it's so accurate and also not very realistic as it hardly ever misses. I'm not even sure what to search for in this case. Any links or thoughts on how to approach this problem would be welcome. Hang

Member Avatar
Member Avatar
+0 forum 5

Hi all, here' the code [CODE] $(document).ready(function(){ $("ul li ul").hide(); $("li:has(ul)").click(function(){ $this = $(this); if ($this.siblings().find('ul:visible').size()!=0) { $this.siblings().find('ul:visible').slideUp(1000, function(){ $this.find('ul:hidden').slideDown(500); }); } else { $this.find('ul:hidden').slideDown(500); } }); $("li:has(ul:hidden)").mousedown(function(){ $(this).css("background-color","#869094"); }).mouseup(function(){ $(this).css("background-color","#7793ae"); }); $("li > ul > li").mousedown(function(){ $(this).css("background-color","#a5ccef"); }).mouseup(function(){ $(this).css("background-color","#d9ebf1"); }); }); [/CODE] The problem is the li:has(ul:hidden) part - line 19. The event triggers regardless of whether the ul is hidden or has been 'slid down' i.e. visible. Interestingly if I change it to li:has(ul:visible) it never triggers. I have tried ("li > ul:hidden").parent("li"), but get the same effect. Can anyone point out what i'm doing wrong? Many thanks

Member Avatar
Member Avatar
+0 forum 2

Please help, I have copied some code to connect to a MSAccess database. However when I try to run it I get a Security Exception message. Weird thing is, in the IDE I can use database explorer to find, open and test the connection to the database. The database is stored on a shard network drive and unfortunatley I cannot access my C: drive [code] using System; using System.Data.OleDb; class OleDbTest{ public static void Main() { //create the database connection OleDbConnection aConnection = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=H:\\Initiatives4.mdb"); //create the command object and store the sql query OleDbCommand aCommand = new OleDbCommand("select …

Member Avatar
Member Avatar
+0 forum 8

The End.