# Why my javascript is not working in FireFox, Help pls



## sniperx

Hi guys, I am trying to get my javascript working in Firefox. I dont know why it is not working in firefox but it works fine on IE and other.

here is my code:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head>

<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<title>Welcome to the Pairwise Biological Sequence Alignment Web Page</title>
</head>

<body>
<h1>Welcome to the Pairwise Biological Sequence Alignment Web Page</h1>



<form action="./cgi-bin/Form.cgi" method="post"> 


<script type="text/javascript">
/* <![CDATA[ */
function disable()
{
document.getElementById("GapPenalty").disabled=true
document.getElementById("LinearD").disabled=true
document.getElementById("AffineD").disabled=true
document.getElementById("AffineE").disabled=true
document.getElementById("email").disabled=truea
}
function enable()
{
document.getElementById("GapPenalty").disabled=false
document.getElementById("LinearD").disabled=false
document.getElementById("AffineD").disabled=false
document.getElementById("AffineE").disabled=false
document.getElementById("email").disabled=false
}
function disable2(what)
{ 
document.getElementById(what).disabled = true; 
} 
function setupper(myfield)
{
if (myfield.inchange)return;
myfield.inchange=true;
myfield.value=myfield.value.toUpperCase();
myfield.inchange=false;
document.getElementById("LinearD").disabled=true
}
function alertMsg(what)
{
if (what == "Affine")
{

document.getElementById("LinearD").disabled=true;
(document.getElementById("LinearD").value)="";

document.getElementById("AffineD").disabled=false;
document.getElementById("AffineE").disabled=false;
} 
else if (what == "Linear")
{

document.getElementById("LinearD").disabled=false;
(document.getElementById("AffineD").value)="";
(document.getElementById("AffineE").value)="";
document.getElementById("AffineD").disabled=true;
document.getElementById("AffineE").disabled=true;
}


}
function checkNum(myfield, e, dec)
{
var key;
var keychar;
if (window.event)
key = window.event.keyCode;
else if (e)
key = e.which;
else
return true;
keychar = String.fromCharCode(key);
// control keys
if ((key==null) || (key==0) || (key==8) || 
(key==9) || (key==13) || (key==27) )
return true;
// numbers
else if ((("0123456789").indexOf(keychar) > -1)) //original ("0123456789") has zero

return true;

// decimal point jump
else if (dec && (keychar == "."))
{
myfield.form.elements[dec].focus();
return false;
}
else
return false;
}
function checkLinearD(linearD){
if (linearD > 10 ){
alert("Please input a number between 1-10");
(document.getElementById("LinearD").value)="";
(document.getElementById("AffineD").value)="";
(document.getElementById("AffineE").value)="";
}

}

function checkAffineD(AffineD){
if (AffineD > 12 ){
alert("Please input a number between 1-12");
(document.getElementById("LinearD").value)="";
(document.getElementById("AffineD").value)="";
(document.getElementById("AffineE").value)="";
}


}

function checkAffineE(AffineE){
if (AffineE > 10 ){
alert("Please input a number between 1-10");
(document.getElementById("LinearD").value)="";
(document.getElementById("AffineE").value)="";
}

}

function checkScore(Score){
if (Score > 99 ){
alert("Please input a number between 1-99");
(document.getElementById("Score").value)="";
}

}

/* ]]> */
</script>




<select onclick="alertMsg(this.value)" onchange="alertMsg(this.value)" name="GapPenalty">
<option value="Linear">Linear</option>
<option value="Affine">Affine</option></select><br />
Linear d (1 - 10)=
<input type="text" onchange="checkLinearD(this.value)" onkeypress="return checkNum(this, event)" maxlength="2" size="2" name="LinearD" /><br />
Affine d (1 - 12)=
<input type="text" disabled="disabled" onchange="checkAffineD(this.value)" onkeypress="return checkNum(this, event)" maxlength="2" size="2" name="AffineD" /><br />
Affine e (1 - 10)=
<input type="text" disabled="disabled" onchange="checkAffineE(this.value)" onkeypress="return checkNum(this, event)" maxlength="2" size="2" name="AffineE" />


<br />
<br />

<br />
<br /><input type="submit" name="Submit" /><input type="reset" value="Clear Your Entries" size="4" /><input type="button" value="Refresh" onclick="history.go(0)" /><br />
</p>
</form>
</body>

</html>


Please let me know why it is not working. It suppose to work when I choose affine, the Affine D and Affine E text box will be enable.


----------



## omega113

I would suggest you to use alert statement in your javascript code in top-to-bottom fashion. THis way it would be easy for you to track where you are going wrong.

Else i would recommend you to use firebug
https://addons.mozilla.org/en-US/firefox/addon/1843

-ANuj
http://*********


----------



## TriChip

1. Open Firefox

2. Go To Tools

3. Go To Options

4. Click On Contents

5. Check the box that says Enable Javascript.


----------



## sniperx

Its ok now, I had it fixed. But I had to rewrite all the javascript from scratch because xhtml takes a tougher standard and syntax than html.

And Firebug would be your best friend if you are stuck like me, however I although I got it working on Firefox. Now my code is not working for IE. So this is great!! isn't it?

My range check function is not working


----------

