PDA

View Full Version : IE7 errors



glab
Jul 14th, 2009, 10:25 AM
Hi guys, am new to this forum. I have a javascript error that i have in my registration page and it is showing only on IE. But in FF2 and OPERA9, the script is working normally ... this is the code:


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Administration Page</title>
<META http-equiv="Content-Script-Type" content="text/javascript;charset=iso-8859-1">
<meta name="generator" content="HAPedit 3.1">
<script type="text/javascript">
var lists = new Array();
lists['Country1'] = new Array();
lists['Country1'][0] = new Array('C1School1','C1School2');
lists['Country1'][1] = new Array('C1School1','C1School2');
lists['Country2'] = new Array();
lists['Country2'][0] = new Array('C2School1','C2School2');
lists['Country2'][1] = new Array('C2School1','C2School2');
lists['C1School1'] = new Array();
lists['C1School1'][0] = new Array('C1S1Class1','C1S1Class2');
lists['C1School1'][1] = new Array('C1S1Class1','C1S1Class2');
lists['C1School2'] = new Array();
lists['C1School2'][0] = new Array('C1S2Class1','C1S2Class2');
lists['C1School2'][1] = new Array('C1S2Class1','C1S2Class2');
lists['C2School1'] = new Array();
lists['C2School1'][0] = new Array('C2S1Class1','C2S1Class2');
lists['C2School1'][1] = new Array('C2S1Class1','C2S1Class2');
lists['C2School2'] = new Array();
lists['C2School2'][0] = new Array('C2S2Class1','C2S2Class2');
lists['C2School2'][1] = new Array('C2S2Class1','C2S2Class2');

function testForm() {
document.getElementById("dumpHere").innerHTML = "";
a = testUsername(document.getElementById('username').value);
c = testPassword(document.getElementById('password').value);
if(checkPass()==true && a==true && c==true){
return true;
} else {
return false;
}
}

function isPassword(x,y) {
return (x != "" && x == y);
}

function writeTo(x){
M = document.getElementById("dumpHere");
M.innerHTML+=x+"<br/>";
return true;
}

function testUsername(v){
if (v.length < 4){
writeTo("Username must be at least 4 characters!!!");
return false;
} else {
return true;
}
}

function testPassword(v){
if (v.length < 4){
writeTo("Password must be at least 4 characters!!!");
return false;
} else {
return true;
}
}

function checkPass(){
if (isPassword(document.getElementById("password").value,document.getElementById("confpassword").value)){
return true;
} else {
writeTo("Password not valid, enter a value and matching value to confirm!!!");
return false;
}
}

function emptyList(box) {
while ( box.options.length ) {
box.options[0] = null;
}
}

function fillList(box,arr) {
for ( i = 0; i < arr[0].length; i++ ) {
option = new Option( arr[0][i], arr[1][i] );
box.options[box.length] = option;
}
box.selectedIndex = 0;
}

function changeList(box) {
list = lists[box.options[box.selectedIndex].value];
emptyList( box.form.school );
fillList( box.form.school, list );
}

function changeList2(box) {
list = lists[box.options[box.selectedIndex].value];
emptyList( box.form.class );
fillList( box.form.class, list );
}
</script>
</head>
<body onload="changeList(document.forms['sign_up'].country);changeList2(document.forms['sign_up'].school);">
<a href="../BOTH/Logout.php">Logout</a><br>
<form name="sign_up" method="POST" action="CheckRegister.php">
<div align="center">
<p>type:
<select name="type" id="type">
<option value="student">student</option>
<option value="teacher">teacher</option>
</select>
<br>
username :
<input type="text" id="username" name="username">
<br>
password :
<input type="text" id="password" name="password">
<br>
confirm :
<input type="text" id="confpassword">
<br>
country :
<select name="country" size=1 onChange="changeList(this);changeList2(school);">
<option value="Country1">Country1</option>
<option value="Country2">Country2</option>
</select>
<br>
school :
<select name="school" size=1 onChange="changeList2(this);">
</select>
<br>
class :
<select name="class" size=1>
</select>
<br>
</p>
<p>
<input type="button" value="Register User" onClick="testForm();if(testForm()==true){document.sign_up.submit();}">
<br>
</p>
</div>
</form>
<div id="dumpHere" align="center"></div>
</body>
</html>

Try this code in FF2 and IE7 and see the difference please.
Thanks in advance for any help.

Amphiluke
Jul 14th, 2009, 10:43 AM
This is because of "class" is a reserved codeword. Do not use it as a name of an object. Replase name="class" with name="_class" for instance.

glab
Jul 14th, 2009, 11:05 AM
Thanks a lot brother... that solved the problem :)