scott100
07-13-2005, 01:38 PM
Can anyone tell me why this code does not work in Firefox, it seems to be a problem with getElementById as i have tried accessing the info using the form name and it works ok, i need to access it using getElementById though. Opera and IE work ok.
Thanks.
<html>
<head>
<script>
function checkintro()
{
var assoc=document.getElementById('housingAssoc').value;
if (assoc=="Please choose")
{alert("You must choose a Housing association");}
else
{alert("Thank you for choosing "+assoc+"");}
}
</script>
</head>
<body>
<form name="housingForm">
<table width="100%" border="0">
<tr>
<td width="25%" align="center" valign="top"></td>
<td width="50%" align="center">
<h2>Glasgow City's Housing Association</h2>
<hr color="black" width="90%" />
<h2>APPLICATION FOR HOUSING</h2>
<br />
Please choose a housing association?<br /><br />
<select name="housingAssoc" size="1" />
<option value="Please choose">Please choose</option>
<option value="Biell">Biell</option>
<option value="Cloch Housing">Cloch Housing</option>
<option value="Rosehill Housing">Rosehill Housing</option>
</select>
</td>
<td width="25%" align="center" valign="top"></div>
</td>
</tr>
</table>
<input type="button" class="button" value="Next ->>" onClick="checkintro()"/>
<br />
</body>
</html>
Thanks.
<html>
<head>
<script>
function checkintro()
{
var assoc=document.getElementById('housingAssoc').value;
if (assoc=="Please choose")
{alert("You must choose a Housing association");}
else
{alert("Thank you for choosing "+assoc+"");}
}
</script>
</head>
<body>
<form name="housingForm">
<table width="100%" border="0">
<tr>
<td width="25%" align="center" valign="top"></td>
<td width="50%" align="center">
<h2>Glasgow City's Housing Association</h2>
<hr color="black" width="90%" />
<h2>APPLICATION FOR HOUSING</h2>
<br />
Please choose a housing association?<br /><br />
<select name="housingAssoc" size="1" />
<option value="Please choose">Please choose</option>
<option value="Biell">Biell</option>
<option value="Cloch Housing">Cloch Housing</option>
<option value="Rosehill Housing">Rosehill Housing</option>
</select>
</td>
<td width="25%" align="center" valign="top"></div>
</td>
</tr>
</table>
<input type="button" class="button" value="Next ->>" onClick="checkintro()"/>
<br />
</body>
</html>