Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 10 of 10
  1. #1
    Regular Coder
    Join Date
    Oct 2003
    Posts
    603
    Thanks
    2
    Thanked 1 Time in 1 Post

    works in Firefox and not IE

    i have a javascript that is initiated when someone hits the "delete" icon for a specific row on a page and it works PERFECTLY in Firefox, but in IE, the rows below the row that is deleted do not change their "num" values nor their names.

    Code:
    function removeRow(num,type){
    if(type == "topsr"){
    var typef = "Top Seniors";
    }else if(type == "topsleep"){
    var typef = "Top Sleepers";
    }else if(type == "topfuture"){
    var typef = "Top Future";
    }
    	var confirmit = confirm("Are you sure you want to remove `"+typef+"` #"+num+"?");
    	if(confirmit){
    		//begin removal process
    		document.getElementById(type+"_"+num+"_value").value='';
    		document.getElementById(type+"_"+num).style.display='none';
    		var currentcount = document.getElementById('num_'+type).value;
    		for(var count=parseInt(num)+1; count <= currentcount; count++){
    			var newnum = count-1;
    			document.getElementById(type+'_'+count+'_num').id=type+'_'+newnum+'_num';
    			document.getElementById(type+'_'+newnum+'_num').name=type+'_'+newnum+'_num';
    			document.getElementById(type+'_'+count).id=type+'_'+newnum;
    			document.getElementById(type+'_'+newnum+'_num').value=parseInt(count)-1;
    			document.getElementById(type+'_'+count+'_value').id=type+'_'+newnum+'_value';
    			document.getElementById(type+'_'+newnum+'_value').name=type+'_'+newnum+'_value';
    		}
    		document.getElementById('num_'+type).value=parseInt(currentcount)-1;
    	}
    }

  • #2
    Regular Coder
    Join Date
    Oct 2003
    Posts
    603
    Thanks
    2
    Thanked 1 Time in 1 Post
    anyone know why Firefox does what my script (above) tells it but IE only works up to the following line:
    Code:
    document.getElementById(type+"_"+num).style.display='none';
    //stops doing what it's told after this
    ???

  • #3
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    var count=parseInt(num)+1

    this could be the problem. If num is something like '08', for instance, parseInt() - which meaning is in fact to parse a number from a base in decimal - will take it as an octal

    try:
    alert(parseInt('08'))
    to see what I mean

    You must set the base

    parseInt(num,10)
    or better use Number() method instead.
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #4
    Regular Coder
    Join Date
    Oct 2003
    Posts
    603
    Thanks
    2
    Thanked 1 Time in 1 Post
    well i can assure you there are no "0"s in it because the php loop uses for($i=1;$i<=$max;$i++){} and if that was the case it wouldnt work in firefox.
    Last edited by boeing747fp; 08-01-2006 at 09:43 AM.

  • #5
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    Can we see the whole code?
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #6
    Regular Coder
    Join Date
    Oct 2003
    Posts
    603
    Thanks
    2
    Thanked 1 Time in 1 Post
    well there's the code above that is in the <head> section
    and this is one of the many nearly identical clauses in PHP (the only difference in the other ones is that they are not the same "section" (topsr, topsleep, etc)
    PHP Code:
    while($rf mysql_fetch_array($dg)){
                
    $dfg mysql_query("SELECT `full_name` FROM `playerprofiles` WHERE `id` = '$rf[player_id]'") or die(mysql_error());
                
    $rbr mysql_fetch_array($dfg);
                
    $player stripslashes($rbr[full_name]);
                echo 
    "<span id=\"topsleep_$rf[num]\" class=\"topsleep_row\">#<input class=\"input\" type='text' size='3' maxlength=\"2\" name=\"topsleep_$rf[num]_num\" id=\"topsleep_$rf[num]_num\" value='$rf[num]'>: <input class=\"input\" tabindex=\"1\" type=\"text\" name=\"topsleep_$rf[num]_value\" value=\"$player\" id=\"topsleep_$rf[num]_value\" onChange=\"document.getElementById('current_number_focus').value='$rf[num]';document.getElementById('current_type_focus').value='topsleep';return checkPlayerName(this.value);\"><a href=\"javascript:moveUp('$rf[num]','topsleep');\"><img src=\"../valueboard/up.gif\" width=\"14\" height=\"15\" border=\"0\"></a><a href=\"javascript:moveDown('$rf[num]','topsleep');\"><img src=\"../valueboard/down.gif\" width=\"14\" height=\"15\" border=\"0\"></a><a href=\"javascript:removeRow('$rf[num]','topsleep');\"><img src=\"../v3/error.gif\" width=\"14\" height=\"15\" border=\"0\"></a><br /></span>";
                } 

  • #7
    Regular Coder
    Join Date
    Oct 2003
    Posts
    603
    Thanks
    2
    Thanked 1 Time in 1 Post
    the problem is that the part that is supposed to make all the rows beneath the removed one subtract 1 number from their value, it doesnt want to do it in IE... it removes the row and keeps their current numbers (so if i remove row # 19, the next row stays #20... but in firefox, it does work and #20 becomes #19)

  • #8
    Regular Coder
    Join Date
    Oct 2003
    Posts
    603
    Thanks
    2
    Thanked 1 Time in 1 Post
    ooo... just noticed IE gives me this error (and firefox doesnt)

    the line is
    Code:
    document.getElementById(type+'_'+count).id=type+'_'+newnum;
    and i get "document.getElementById(type+'_'+count) is null or not an object"

  • #9
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    that could mean that either "type" or "count" or both are not defined. Or the object does not exist.

    Use alert() method from line to line to check different things. It is a good "debug" way.

    On the other hand, IE, specially, is very nervous when using variable named as javascript reserved words, or even the same as the window or document properties. Could be "type?
    ----
    FireFox console is of a good help in cases like that... You might hev forget to close the function, or the brackets... or... FF console is good in case of.
    Last edited by Kor; 08-01-2006 at 11:24 PM.
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #10
    Regular Coder
    Join Date
    Oct 2003
    Posts
    603
    Thanks
    2
    Thanked 1 Time in 1 Post
    nope that didnt do it either... the weirdest thing is that it works in firefox. usually it's backwards (works in IE and not firefox) but this situation is baffling.


  •  

    Posting Permissions

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