Click to See Complete Forum and Search --> : Very strange form-error
mf22cs
04-27-2003, 03:59 PM
Check this code out:
function checkName(theForm) {
document.getElementById("p_namn").innerHTML = theForm.name.value;
}
function checkAge(theForm) {
document.getElementById("p_alder").innerHTML = theForm.age.value + " år";
}
What is wrong with the first function? In Netscape it works just fine, but in IE i don´t...
Please help...
/marcus
The function looks fine to me... you may want to post the rest of you code, as there could be a problem with something else. Also, what version of IE are you using?
mf22cs
04-27-2003, 04:34 PM
Thanx for the fast comment... :)
Well, browserversion...
IE 6.0.2800.1106.xpsp1.020828-1920 with the following updates SP1, Q810847 and Q813951
NN 7.02 (Gecko/20030208 Netscape/7.02)
OK! Here comes the complete code:
<html>
<head>
<title>Pagename</title>
<script language="javascript">
<!--
function checkName(theForm) {
document.getElementById("p_namn").innerHTML = theForm.name.value;
}
function checkAge(theForm) {
document.getElementById("p_alder").innerHTML = theForm.age.value + " år";
}
function checkSex(theForm) {
var kon;
if (theForm.sex[0].checked == true) {
kon = theForm.sex[0].value;
}
if (theForm.sex[1].checked == true) {
kon = theForm.sex[1].value;
}
document.getElementById("p_kon").innerHTML = kon;
}
// -->
</script>
</head>
<body>
<form>
<table>
<tr>
<td>Namn:</td>
<td><input name="name" style="width: 150px;" onBlur="checkName(this.form)" /></td>
</tr><tr>
<td>Ålder:</td>
<td>
<select name="age" style="width: 150px;" onChange="checkAge(this.form)">
<option value="-">Välj ålder</option>
<option value="15">15 år</option>
<option value="16">16 år</option>
<option value="17">17 år</option>
<option value="18">18 år</option>
<option value="19">19 år</option>
<option value="20">20 år</option>
<option value="21">21 år</option>
<option value="22">22 år</option>
<option value="23">23 år</option>
<option value="24">24 år</option>
<option value="25">25 år</option>
</select>
</td>
</tr><tr>
<td>Kön:</td>
<td>
<input name="sex" type="radio" value="Man" onClick="checkSex(this.form)" /> Man
<input name="sex" type="radio" value="Kvinna" onClick="checkSex(this.form)" /> Kvinna
</td>
</tr>
<table>
</form>
<p id="p_namn"> </p>
<p id="p_alder"> </p>
<p id="p_kon"> </p>
</body>
</html>
That´s it. (In all of the P-tags there are a "No-Brake-SPace")
Please help me solve this one...
/Marcus
mf22cs
04-27-2003, 05:08 PM
Hello...
Well, what can I say... There is one* bug in IE generating that error...
The solotion is to put a between the line with </form> and the line with <p id="p_namn"> </p>.
/Marcus
* = at least...
mf22cs
04-27-2003, 05:09 PM
The solution is to put a No-Brake-SPace between....
mf22cs
04-27-2003, 05:31 PM
There is no bug in IE... I just saw that I missed the correct ending of an table in HTML...
/Marcus - very red-faced...