PDA

View Full Version : Page not working in firefox


greatguns
03-02-2006, 03:22 PM
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Register for Service</title>
<link type="text/css" rel="stylesheet" href="styles.css" />
<script language="JavaScript" type="text/javascript">
function unhidefrm(str) {
if(str=="tt Service") {
phnotb.style.display="inline";
report.style.display="none";
}
else if(str=="Reports")
{
phnotb.style.display="none";
report.style.display="inline";
}
else if(str=="service")
{
phnotb.style.display="none";
report.style.display="none";
}
}</script>
</head>
<body>
<br />
<br />
<br />
<center>



<select align="center" name="servicesel" onchange="unhidefrm(this.value)"><option value="service" selected="selected" >Select A Service</option><option value="tt Service">tt Service</option>

<option value="Others">Others</option>
<option value="Reports">Reports</option>
</select>

<br /><br /><br />
<table id="report" style="display:none" align="center">
<tr>
<td><h1>No Need To Register For Reports</h1></td>
</tr>
<tr>

<td align="center"><input type="button" value="Back" onclick="history.back()" /></td>
</tr>
</table>
<form name="regserv" method="post" action="register_service.jsp" onsubmit='return valphno()'>
<table id="phnotb" align="left" width="80%" cellspacing="5" cellpadding="5" style="display:none">
<tr align="center" >
<td width="54%" align="right"><label><b>Your val</b></label></td>
<td width="46%" align="left"><input type="text" size="20" name="ttlphno" onkeypress ="numOnly()"/></td>

</tr>

<tr>
<td>&nbsp;</td>
</tr>
<tr>
<td height="43">&nbsp;</td>
<td><input name="Submit" type="submit" value="Submit" /></td>
<td>&nbsp;</td>

</tr>
</table>

<input type="hidden" value="1" name="submitmode" />
</form>
<h1>&nbsp;</h1>
<h1>&nbsp;</h1>
<h1>&nbsp;</h1>
<h1>&nbsp;</h1>
</center>

</body>
</html>


Thats my code....it works fine in IE/Opera and other browsers.

but firefox gives the javascript error phnotb is not defined....

pleaseeee help....this error is driving me crazy since 2 days :crying:

scoutt
03-03-2006, 06:40 PM
I will move this to the javascirpt forum and I will also tell you why it errors.

you named a table id="phnotb" and that javascirpt is bad as it is looking for a name, not an id.

coothead
03-03-2006, 07:24 PM
Hi there greatguns,

scoutt has hinted the solution to your problem...

document.getElementById

...so change the script to this...
function unhidefrm(str) {
if(str=="tt Service") {
document.getElementById('phnotb').style.display="inline";
document.getElementById('report').style.display="none";
}
else if(str=="Reports") {
document.getElementById('phnotb').style.display="none";
document.getElementById('report').style.display="inline";
}
else if(str=="service") {
document.getElementById('phnotb').style.display="none";
document.getElementById('report').style.display="none";
}
}
</script>

greatguns
03-05-2006, 09:39 AM
@scoutt
i thought the same too and used the name as well as ID for the table but it still didnt work.

@coothead
The modified script works perfectly. Thx a million :D

thx for the help guys

scoutt
03-05-2006, 02:02 PM
@scoutt
i thought the same too and used the name as well as ID for the table but it still didnt work.
The code you just got from coothead is what I just said. He used the ID instead of the name. so apparently it does work :)

greatguns
03-05-2006, 03:11 PM
ahh..k

damm firefox was the only one unable to handle the script. now everything works

scoutt
03-05-2006, 10:33 PM
Sorry, but it was IE's interpratation of javascript that is wrong. you should be using ID anyway.