Flash Website Builder- Trendy Site Builder is a Flash Site Building tool that helps users build stunning websites. Check Out Custom Custom Logo Design by LogoBee. Website Design and Free Logo Templates available.

Before you post, read our: Rules & Posting Guidelines

Enjoy an ad free experience by logging in. Not a member yet? Register.
 03-17-2009, 09:19 PM PM User | #1 bilbo.baggins New to the CF scene   Join Date: Mar 2009 Posts: 4 Thanks: 1 Thanked 0 Times in 0 Posts This makes no sense, please help! I am relatively new to JavaScript, and I am having serious problems over a JavaScript function. I have 2 x 2 dimensional arrays of data to display on the screen, each array being 18 x 18. The arrays and displaying them is working fine, I have 2 lots of X and Y variable (LocX1, LocY1, LocX2 and LocY2) which I use to reference the cells of the arrays. I have 2 similar (but not identical) functions to move around these arrays using links on the screen. Function 1 moves around the first array and is fine - Code: ```function MoveMapView(strDirection) { if (strDirection == "North") { LocY2 -= 1; if (LocY2 < 0){ LocY2 = 0; } } if (strDirection == "East") { LocX2 += 1; if (LocX2 > 17){ LocX2 = 17; } } if (strDirection == "South") { LocY2 += 1; if (LocY2 > 17){ LocY2 = 17; } } if (strDirection == "West") { LocX2 -= 1; if (LocX2 < 0){ LocX2 = 0; } } //Call the display functions .. .. }``` However function 2 (below) adds one to the end of LocY2 as though it was a string when you click the link for 'South'. Code: ``` function MoveSector(strDirection) { if (strDirection == "North") { LocY1 -= 1; if (LocY1 < 0){ LocY1 = 0; } } if (strDirection == "East") { LocX1 += 1; if (LocX1 > 17){ LocX1 = 17; } } if (strDirection == "South") { LocY1 += 1; if (LocY1 > 17){ LocY1 = 17; } } if (strDirection == "West") { LocX1 -= 1; if (LocX1 < 0){ LocX1 = 0; } } //Sava data to the cookie strText = "LocX1=" + LocX1; document.cookie = strText; strText = "LocY1=" + LocY1; document.cookie = strText; //Redirect location.replace('load.asp'); }``` At the top of the page I have a routine to make sure that the numbers are numbers (as below). Code: ```// Make sure Location data is a number, may have been turned into a string // LocX1= LocX1 + 0; // LoxY1= LocY1 + 0; // LocX2= LocX2 * 1; // LoxY2= LocY2 * 1; LocX1= Number (LocX1); LoxY1= Number (LocY1); LocX2= Number (LocX2); LoxY2= Number (LocY2);``` As you can see, I have tried multiplying the variable by 1, adding zero and using the Number command. All other directions work fine and all links are identical, just passing a different 'direction' through an onClick. I know I am probably making a very simple and obvious mistake, but ANY help is appreciated. At this rate I will have no hair as well as no life! Thanks
 03-17-2009, 10:46 PM PM User | #2 tomws Senior Coder     Join Date: Nov 2007 Location: Arkansas Posts: 2,644 Thanks: 29 Thanked 330 Times in 326 Posts You don't mention actually using any framework, so this probably would have bene better placed up in the main javascript forum. Would have received a good number of responses, too. Maybe the problem is in the function call itself. Check that area of the code and see what you're actually passing. __________________ Are you a Help Vampire?
 03-18-2009, 01:36 AM PM User | #3 bilbo.baggins New to the CF scene   Join Date: Mar 2009 Posts: 4 Thanks: 1 Thanked 0 Times in 0 Posts Cheers Tomws, this had done my head in I had miss read where I posted it ... will re-post in proper place

 Bookmarks

 Thread Tools Rate This Thread Rate This Thread: 5 : Excellent 4 : Good 3 : Average 2 : Bad 1 : Terrible

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is On HTML code is Off Forum Rules
 Forum Jump User Control Panel Private Messages Subscriptions Who's Online Search Forums Forums Home :: Client side development     JavaScript programming         DOM and JSON scripting         Ajax and Design         JavaScript frameworks         Post a JavaScript     HTML & CSS     XML     Flash & ActionScript         Adobe Flex     Graphics and Multimedia discussions     General web building         Site reviews         Building for mobile devices :: Server side development     Apache configuration     Perl/ CGI     PHP         Post a PHP snippet     MySQL         Other Databases     Ruby & Ruby On Rails     ASP     ASP.NET     Java and JSP     Other server side languages/ issues         ColdFusion         Python :: Computing & Sciences     Computer Programming     Computer/PC discussions     Geek News and Humour Web Projects and Services Marketplace     Web Projects         Small projects (quick fixes and changes)         Medium projects (new script, new features, etc)         Large Projects (new web application, complex features etc)         Unknown sized projects (request quote)         Vacant job positions         Looking for work/ for hire         Project collaboration/ partnership         Paid work offers and requests (Now CLOSED)     Career, job, and business ideas or advice     Domains, Sites, and Designs for sale         Domains for sale         Websites for sale         Design templates and graphics for sale :: Other forums     Member Offers     Forum feedback and announcements

All times are GMT +1. The time now is 03:03 PM.