[Cross browser Form Population] FireFox vs. IE weirdness.

admin

Administrator
Staff member
Hi all!

I have this page that works perfectly on Mozilla FireFox, but pukes when it it run on IE. I am sure I am making a small mistake somewhere that I just cannot seem to find. There is no syntax error, it must be a logical (or browser) error.

I have attached the code.
I know that I should not post my whole script, but, it's kind of difficult seeing that I do not know where the problem is, and that you actually need all the parts to see what I am trying to do.

What it should do:
Draw the matrix from the given arrays, gender, race, occ. Then, after the whole document is loaded, fill the matrix with the given values in the fill array.

What it is actually doing:
Mozilla FireFox: Works fine and as suspected.
MSIE: No Javascript errors, but, the fillMatrix() function does not work as it should. It does not fill the input fields, or sometimes fills them with the wrong values. IE does not seem to get to the correct input field.

My Question:
Can someone perhaps help me to point out what is going wrong on IE?

Any suggestions on improving the code would also be welcome. ;)

Thanks in advance.


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Matrix</title>
<meta content="Tue, 20 Aug 1996 14:25:00 GMT" http-equiv="Expires">
<meta http-equiv="pragma" content="no-cache">
</head>
<body>
<script language="JavaScript" type="text/javascript">
var
gender = new Array (null,"F|Female","M|Male");
race = new Array (null,"B|African","C|Coloured","I|Indian","W|White");
occ = new Array (null,"01|Top Management","02|Senior Management","03|Mid-Management","04|Junior Management","05|Semi-skilled and Discretionary Decision Making","06|Unskilled and Defined Decision Making");
fill = new Array (null,"01|F|B|5");
ARRSEPERATOR = "|";
SEPERATOR = ",";

function
parseMatrix(v_form)
{
var v_tmp = new String;

for (var i = 1; i < occ.length; ++i)
{
var t_occArray = occ.split(ARRSEPERATOR);

for (var j = 1; j < gender.length; ++j)
{
var t_genderArray = gender[j].split(ARRSEPERATOR);


for (var k = 1; k < race.length; ++k)
{

var t_raceArray = race[k].split(ARRSEPERATOR);

var itemName = t_occArray[0] + ARRSEPERATOR + t_genderArray[0] + ARRSEPERATOR + t_raceArray[0];
if ((itemValue = v_form[itemName].value) == "")
itemValue = 0;

v_tmp += itemName + ARRSEPERATOR + itemValue + SEPERATOR;
}
}
}
if (v_tmp.substr(v_tmp.length - SEPERATOR.length,SEPERATOR.length) == SEPERATOR)
v_tmp = v_tmp.substr(0, v_tmp.length - SEPERATOR.length);

v_form.figureString.value = v_tmp;
alert (v_form.figureString.value);
return 0;
}

function fillMatrix(v_formObj)
{
var fillSplit = new Array();

for (var i = 1; i < fill.length; ++i)
{
if (fill != null)
{
fillSplit = fill.split(ARRSEPERATOR);
if (fillSplit.length == 4)
{
var itemName = fillSplit[0] + ARRSEPERATOR + fillSplit[1] + ARRSEPERATOR + fillSplit[2];
//alert ("fillsplit[" + i + "] == " + itemName + "(" + fillSplit[3] + ")");
//alert(v_formObj[itemName].value);
v_formObj[itemName].value = fillSplit[3];
}
}
}
return 0;
}

window.onload = function()
{
fillMatrix(document.frm_Matrix);
}
</script>

<form action="" method="post" name="frm_Matrix">
<input name="args" type="Hidden" value=http://www.webdeveloper.com/forum/archive/index.php/"sessionID,figureString">
<input name="figureString" type="Hidden" value="">

<script language="JavaScript" type="text/javascript">
document.writeln ('<table border=\"1\" width=\"100%\">');
for (var j = 1; j < gender.length; ++j)
{
if (j == 1)
{
document.writeln ('<tr>');
document.writeln ('<td>Gender</td>');
}

if (gender[j] != null)
{
var t_genderArray = gender[j].split (ARRSEPERATOR);
var cs = race.length - 1;
document.writeln ('<th colspan=\"' + cs + '\">' + t_genderArray[1] + '</th>');
}
if (j == (gender.length - 1))
document.writeln ('</tr>');
}

for (var i = 1; i < occ.length; ++i)
{
var t_occArray = occ.split (ARRSEPERATOR);

if (i == 1)
{
for (var j = 1; j < gender.length; ++j)
{
if (j == 1)
{
document.writeln ('<tr>');
document.writeln ('<td>Race</td>');
}

for (var k = 1; k < race.length; ++k)
{
var t_raceArray = race[k].split (ARRSEPERATOR);
document.writeln ('<th>' + t_raceArray[1] + '</th>');
}

if (j == (gender.length - 1))
document.writeln ('</tr>');
}
}

for (var j = 1; j < gender.length; ++j)
{
t_genderArray = gender[j].split (ARRSEPERATOR);

if (j == 1)
{
document.writeln ('<tr>');
document.writeln ('<td>' + t_occArray[1] + '</td>');
}

for (var k = 1; k < race.length; ++k)
{
t_raceArray = race[k].split(ARRSEPERATOR);
document.write ('<td>');
//alert (t_occArray[0] + ARRSEPERATOR + t_genderArray[0] + ARRSEPERATOR + t_raceArray[0]);
document.write ('<input name=\"' + t_occArray[0] + ARRSEPERATOR + t_genderArray[0] + ARRSEPERATOR + t_raceArray[0] + '\" size=\"4\" maxlength=\"4\">');
document.writeln ('</td>');
}

if (j == (gender.length - 1))
document.writeln ('</tr>');
}
}
document.writeln ('</table>');
</script>
</form>
</body>
</html>
 
Top