View Full Version : works in Firefox and not IE

07-31-2006, 05:35 PM
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.

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+"?");
//begin removal process
var currentcount = document.getElementById('num_'+type).value;
for(var count=parseInt(num)+1; count <= currentcount; count++){
var newnum = count-1;

08-01-2006, 07:55 AM
anyone know why Firefox does what my script (above) tells it but IE only works up to the following line:

//stops doing what it's told after this


08-01-2006, 09:59 AM
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

to see what I mean

You must set the base

or better use Number() method instead.

08-01-2006, 10:37 AM
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.

08-01-2006, 10:45 AM
Can we see the whole code?

08-01-2006, 10:51 AM
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)

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>";

08-01-2006, 10:56 AM
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)

08-01-2006, 10:51 PM
ooo... just noticed IE gives me this error (and firefox doesnt)

the line is

and i get "document.getElementById(type+'_'+count) is null or not an object"

08-02-2006, 12:19 AM
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.

08-02-2006, 12:23 AM
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.