www.webdeveloper.com
Results 1 to 5 of 5

Thread: issue that I dont understand help please

  1. #1
    Join Date
    Mar 2012
    Posts
    41

    issue that I dont understand help please

    dev site

    So in there what Im doing is a spreadsheet like application. Now columns 4 and 5 have an input that triggers onkeyup. Those columns have the same name attribute but have different ids. The function determines where the keyup came from using css class name and gets the collection of objects from the other column, meaning that if I trigger from column 4 it collects column 5 and vice-versa. Now the problem lies on the 3 item, the "205 separator", if you look line 385/386 in the CalcCols() it grabs the price and the life therefore making the wrong calculation on EI9 but works on firefox. I simply do not get why getting elements by name "3" grabs this one that its name is "4".

    Can any be so kind to look at this?

    Thanks.

  2. #2
    Join Date
    Oct 2010
    Location
    Versailles, France
    Posts
    1,266
    I believe to understand that there is a confusion between the name of the variable and his rank. It could be a question of quotation marks in MySql.
    Since the following method give currency strings
    Code:
    Number.prototype.toCurrencyString=function(){
    	return '$'+(this|0).toFixed(2).replace(/(\d)(?=(\d{3})+\b)/g,'$1,');} 
    
    alert ("-123456789.0123".toCurrencyString()) // $-123.456.789,01;

  3. #3
    Join Date
    Mar 2012
    Posts
    41
    I guess Im not following your response. The code you posted is from the formatCurrency(), which happens after the fact. The problem is when I do
    Code:
    var newcName = parseInt(cName)-1;
    var cols = document.getElementsByName(newcName);
    when newcName = 3, it grtabs all elements with name 3 and the one with name 4.
    Code:
    for(var x=0;x<cols.length;x++){
                if(x==3){
                    x++; //this here is a temp fix
                }
                //alert(cols[x].id);
                //alert(x);
                if(cols[x].id == id){
                    aCost = cols[x].value;
                    //alert(aCost);
                }
            }
    Here when x=3 you can clearly see that it grabs the one element with name 4, throwing off my calculations. Why is doing this is what i do not get.

  4. #4
    Join Date
    Nov 2002
    Location
    Flint, Michigan, USA
    Posts
    593
    Quote Originally Posted by blak422 View Post
    ... Those columns have the same name attribute but have different ids. ...
    Don't the name and ID values have to match on each item for it to be valid html?
    Please give me a hand at http://www.gofundme.com/bkzr98.

  5. #5
    Join Date
    Oct 2010
    Location
    Versailles, France
    Posts
    1,266
    This extract of jQuery uncompressed source (lines 164 to 178) show that IE and Opera return items by name instead of ID in certain circumstances...
    Code:
    elem = document.getElementById( match[2] );
    	// Check parentNode to catch when Blackberry 4.6 returns
    	// nodes that are no longer in the document #6963
    	if ( elem && elem.parentNode ) {
    		// Handle the case where IE and Opera return items
    		// by name instead of ID
    		if ( elem.id !== match[2] ) {
    			return rootjQuery.find( selector );
    		}		
    	// Otherwise, we inject the element directly into the jQuery object
    	this.length = 1;
    	this[0] = elem;
    }
    Last edited by 007Julien; 06-01-2012 at 12:50 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles