i have a section of a form that uses radio buttons to give results.
this works fine in firefox, but in Internet Explorer once you have chosen the selections a few times it doesn't work.
can anyone help me out?
thanks!
form.asp
<html>
<head>
<title></title>
<script language="JavaScript" type="text/javascript" src="calculate.js"></script>
</head>
<body style="border:0">
<form name="calc" method="POST">
<div id="ValidationResult" style="visibility: hidden;"></div>
<table width="558" cellpadding="3" cellspacing="0" class="main">
<tr>
<td width="49%" align="center"><table width="270" border="0" cellpadding="0" cellspacing="0">
<tr>
<td valign="top"><table width="119" height="142" border="0" cellpadding="0" cellspacing="0"
class="main">
<tr>
<td width="50%" height="30" valign="top" align="center"><strong>size</strong></td>
</tr>
<tr>
<td width="50%" valign="top" align="center"><input name="option1" type="radio" value="s"
onClick="count(document.calc.option1.value=this.value)" class="None">
S </td>
</tr>
<tr>
<td valign="top" align="center"><input name="option1" type="radio" value="m"
onClick="count(document.calc.option1.value=this.value)" class="None">
M </td>
</tr>
<tr>
<td width="50%" valign="top" align="center"><input name="option1" type="radio" value="l"
onClick="count(document.calc.option1.value=this.value)" class="None">
L </td>
</tr>
<tr>
<td valign="top" align="center"><input name="option1" type="radio" value="xl"
onClick="count(document.calc.option1.value=this.value)" class="None">
XL </td>
</tr>
</table></td>
<td valign="top"><table width="125" height="142" border="0" cellpadding="0" cellspacing="0"
class="main">
<tr>
<td width="50%" height="30" valign="top" align="center"><strong>color</strong></td>
</tr>
<tr>
<td width="50%" valign="top" align="center"><input name="option2" type="radio" value="Red"
onClick="count(document.calc.option2.value=this.value)" class="None">
Red</td>
</tr>
<tr>
<td valign="top" align="center"><input name="option2" type="radio" value="Blue"
onClick="count(document.calc.option2.value=this.value)" class="None">
Blue</td>
</tr>
</table></td>
</tr>
</table></td>
<td width="51%" align="center"><p> </p>
<table width="247" border="1" cellpadding="3" cellspacing="0" bordercolor="#CCCCCC" class="main">
<tr>
<td align="left">postage<br>
</td>
<td align="left"><input name="postage" type="text" class="main" id="postage" size="8">
</td>
</tr>
<tr>
<td width="50%" align="left">packaging<br>
</td>
<td width="50%" align="left"><input name="packaging" type="text" class="main" id="packaging"
size="8">
</td>
</tr>
<tr>
<td align="left">delivery<br>
</td>
<td align="left"><input name="delivery" type="text" class="main" id="delivery" size="8">
</td>
</tr>
<tr>
<td align="left">specialdelivery</td>
<td align="left"><input name="specialdelivery" type="text" class="main" id="specialdelivery"
size="8">
</td>
</tr>
<tr>
<td align="left">admincharge<br>
</td>
<td align="left"><input name="admincharge" type="text" class="admincharge" size="8">
</td>
</tr>
<tr>
<td align="left">total</td>
<td align="left"><input name="total" type="text" class="main" size="8" >
</td>
</tr>
</table></td>
</tr>
</table>
</form>
</body>
</html>
checkoptions.asp
<%
If Request.ServerVariables("QUERY_STRING") = "option1=s&option2=Red" Then
Response.Write("10.00")
End If
If Request.ServerVariables("QUERY_STRING") = "option1=s&option2=Blue" Then
Response.Write("11.00")
End If
If Request.ServerVariables("QUERY_STRING") = "option1=m&option2=Red" Then
Response.Write("20.00")
End If
If Request.ServerVariables("QUERY_STRING") = "option1=m&option2=Blue" Then
Response.Write("22.00")
End If
If Request.ServerVariables("QUERY_STRING") = "option1=l&option2=Red" Then
Response.Write("30.00")
End If
If Request.ServerVariables("QUERY_STRING") = "option1=l&option2=Blue" Then
Response.Write("33.00")
End If
If Request.ServerVariables("QUERY_STRING") = "option1=xl&option2=Red" Then
Response.Write("40.00")
End If
If Request.ServerVariables("QUERY_STRING") = "option1=xl&option2=Blue" Then
Response.Write("44.00")
End If
%>
calculate.asp
var strAgentString = navigator.userAgent.toLowerCase(); // The agent info from the browser
var strBrowser; // Full browser name
var strBrowserCode; // Brief browser code
var strBrowserVersion; // Browser version
var strOS; // Operating system
var strWorkString; // Work string
if (InAgentString('konqueror'))
{
strBrowser = "Konqueror";
strOS = "Linux";
}
else if (InAgentString('firefox')) {
strBrowser = "Firefox";
strBrowserCode = "FF";
}
else if (InAgentString('icab')) {
strBrowser = "iCab";
strBrowserCode = "IC";
}
else if (InAgentString('msie')) {
strBrowser = "Internet Explorer";
strBrowserCode = "IE";
}
else if (InAgentString('omniweb')) {
strBrowser = "OmniWeb";
strBrowserCode = "OW";
}
else if (InAgentString('opera')) {
strBrowser = "Opera";
strBrowserCode = "OP";
}
else if (InAgentString('safari')) {
strBrowser = "Safari";
strBrowserCode = "SA";
}
else if (InAgentString('webtv')) {
strBrowser = "WebTV";
strBrowser = "WT";
}
else if (!InAgentString('compatible'))
{
strBrowser = "Netscape Navigator";
strBrowserCode = "NN";
strBrowserVersion = strAgentString.charAt(8);
}
else
{
strBrowser = "An unknown browser";
strBrowserCode = "XX";
}
if (!strBrowserVersion) strBrowserVersion = strAgentString.charAt(intPos + strWorkString.length);
if (!strOS)
{
if (InAgentString('linux')) strOS = "Linux";
else if (InAgentString('x11')) strOS = "Unix";
else if (InAgentString('mac')) strOS = "Mac"
else if (InAgentString('win')) strOS = "Windows"
else strOS = "An unknown OS";
}
function InAgentString(string) {
intPos = strAgentString.indexOf(string) + 1;
strWorkString = string;
return intPos;
}
function GetXmlHttpObject() {
var xmlHttp=null
if (navigator.userAgent.indexOf("Opera")>=0)
{
xmlHttp=new XMLHttpRequest()
return xmlHttp
}
if (navigator.userAgent.indexOf("MSIE")>=0)
{
var strName="Msxml2.xmlHttp"
if (navigator.appVersion.indexOf("MSIE 5.5")>=0)
{
strName="Microsoft.xmlHttp"
}
try
{
xmlHttp=new ActiveXObject(strName)
return xmlHttp
}
catch(e)
{
alert("Error. Scripting for ActiveX might be disabled")
return
}
}
if (navigator.userAgent.indexOf("Mozilla")>=0)
{
xmlHttp=new XMLHttpRequest()
return xmlHttp
}
}
function count() {
stroption1 = document.calc.option1.value
stroption2 = document.calc.option2.value
var xmlHttp;
xmlHttp = GetXmlHttpObject();
xmlHttp.onreadystatechange=function()
{
if(xmlHttp.readyState==4)
{
total("ValidationResult", xmlHttp.responseText);
results("ValidationResult", xmlHttp.responseText);
return xmlHttp.responseText;
}
}
var URL = "checkoptions.asp";
URL = URL + "?option1=" + stroption1;
URL = URL + "&option2=" + stroption2;
xmlHttp.open("GET",URL,true);
xmlHttp.send(null);
}
function total(strDiv, strMessage) {
if (strBrowserCode == "IE" || strBrowserCode == "FF" || strBrowserCode == "NN" || strBrowserCode ==
"OP" || strBrowserCode == "SA")
{
document.getElementById(strDiv).innerHTML=strMessage;
document.calc.total.value=strMessage;
}
return true;
}
function results(strDiv, strMessage) {
if (document.calc.total.value == "10.00")
{
document.getElementById(strDiv).innerHTML=strMessage;
document.calc.postage.value="1.00";
document.calc.packaging.value="1.00";
document.calc.delivery.value="1.00";
document.calc.specialdelivery.value="1.00";
document.calc.admincharge.value="1.00";
}
{
if (document.calc.total.value == "11.00")
{
document.getElementById(strDiv).innerHTML=strMessage;
document.calc.postage.value="2.00";
document.calc.packaging.value="2.00";
document.calc.delivery.value="2.00";
document.calc.specialdelivery.value="2.00";
document.calc.admincharge.value="2.00";
}
{
if (document.calc.total.value == "20.00")
{
document.getElementById(strDiv).innerHTML=strMessage;
document.calc.postage.value="3.00";
document.calc.packaging.value="3.00";
document.calc.delivery.value="3.00";
document.calc.specialdelivery.value="3.00";
document.calc.admincharge.value="3.00";
}
{
if (document.calc.total.value == "22.00")
{
document.getElementById(strDiv).innerHTML=strMessage;
document.calc.postage.value="4.00";
document.calc.packaging.value="4.00";
document.calc.delivery.value="4.00";
document.calc.specialdelivery.value="4.00";
document.calc.admincharge.value="4.00";
}
{
if (document.calc.total.value == "30.00")
{
document.getElementById(strDiv).innerHTML=strMessage;
document.calc.postage.value="5.00";
document.calc.packaging.value="5.00";
document.calc.delivery.value="5.00";
document.calc.specialdelivery.value="5.00";
document.calc.admincharge.value="5.00";
}
{
if (document.calc.total.value == "33.00")
{
document.getElementById(strDiv).innerHTML=strMessage;
document.calc.postage.value="6.00";
document.calc.packaging.value="6.00";
document.calc.delivery.value="6.00";
document.calc.specialdelivery.value="6.00";
document.calc.admincharge.value="6.00";
}
{
if (document.calc.total.value == "40.00")
{
document.getElementById(strDiv).innerHTML=strMessage;
document.calc.postage.value="7.00";
document.calc.packaging.value="7.00";
document.calc.delivery.value="7.00";
document.calc.specialdelivery.value="7.00";
document.calc.admincharge.value="7.00";
}
{
if (document.calc.total.value == "44.00")
{
document.getElementById(strDiv).innerHTML=strMessage;
document.calc.postage.value="8.00";
document.calc.packaging.value="8.00";
document.calc.delivery.value="8.00";
document.calc.specialdelivery.value="8.00";
document.calc.admincharge.value="8.00";
}
return true;
}
}
}
}
}
}
}
}
this works fine in firefox, but in Internet Explorer once you have chosen the selections a few times it doesn't work.
can anyone help me out?
thanks!
form.asp
<html>
<head>
<title></title>
<script language="JavaScript" type="text/javascript" src="calculate.js"></script>
</head>
<body style="border:0">
<form name="calc" method="POST">
<div id="ValidationResult" style="visibility: hidden;"></div>
<table width="558" cellpadding="3" cellspacing="0" class="main">
<tr>
<td width="49%" align="center"><table width="270" border="0" cellpadding="0" cellspacing="0">
<tr>
<td valign="top"><table width="119" height="142" border="0" cellpadding="0" cellspacing="0"
class="main">
<tr>
<td width="50%" height="30" valign="top" align="center"><strong>size</strong></td>
</tr>
<tr>
<td width="50%" valign="top" align="center"><input name="option1" type="radio" value="s"
onClick="count(document.calc.option1.value=this.value)" class="None">
S </td>
</tr>
<tr>
<td valign="top" align="center"><input name="option1" type="radio" value="m"
onClick="count(document.calc.option1.value=this.value)" class="None">
M </td>
</tr>
<tr>
<td width="50%" valign="top" align="center"><input name="option1" type="radio" value="l"
onClick="count(document.calc.option1.value=this.value)" class="None">
L </td>
</tr>
<tr>
<td valign="top" align="center"><input name="option1" type="radio" value="xl"
onClick="count(document.calc.option1.value=this.value)" class="None">
XL </td>
</tr>
</table></td>
<td valign="top"><table width="125" height="142" border="0" cellpadding="0" cellspacing="0"
class="main">
<tr>
<td width="50%" height="30" valign="top" align="center"><strong>color</strong></td>
</tr>
<tr>
<td width="50%" valign="top" align="center"><input name="option2" type="radio" value="Red"
onClick="count(document.calc.option2.value=this.value)" class="None">
Red</td>
</tr>
<tr>
<td valign="top" align="center"><input name="option2" type="radio" value="Blue"
onClick="count(document.calc.option2.value=this.value)" class="None">
Blue</td>
</tr>
</table></td>
</tr>
</table></td>
<td width="51%" align="center"><p> </p>
<table width="247" border="1" cellpadding="3" cellspacing="0" bordercolor="#CCCCCC" class="main">
<tr>
<td align="left">postage<br>
</td>
<td align="left"><input name="postage" type="text" class="main" id="postage" size="8">
</td>
</tr>
<tr>
<td width="50%" align="left">packaging<br>
</td>
<td width="50%" align="left"><input name="packaging" type="text" class="main" id="packaging"
size="8">
</td>
</tr>
<tr>
<td align="left">delivery<br>
</td>
<td align="left"><input name="delivery" type="text" class="main" id="delivery" size="8">
</td>
</tr>
<tr>
<td align="left">specialdelivery</td>
<td align="left"><input name="specialdelivery" type="text" class="main" id="specialdelivery"
size="8">
</td>
</tr>
<tr>
<td align="left">admincharge<br>
</td>
<td align="left"><input name="admincharge" type="text" class="admincharge" size="8">
</td>
</tr>
<tr>
<td align="left">total</td>
<td align="left"><input name="total" type="text" class="main" size="8" >
</td>
</tr>
</table></td>
</tr>
</table>
</form>
</body>
</html>
checkoptions.asp
<%
If Request.ServerVariables("QUERY_STRING") = "option1=s&option2=Red" Then
Response.Write("10.00")
End If
If Request.ServerVariables("QUERY_STRING") = "option1=s&option2=Blue" Then
Response.Write("11.00")
End If
If Request.ServerVariables("QUERY_STRING") = "option1=m&option2=Red" Then
Response.Write("20.00")
End If
If Request.ServerVariables("QUERY_STRING") = "option1=m&option2=Blue" Then
Response.Write("22.00")
End If
If Request.ServerVariables("QUERY_STRING") = "option1=l&option2=Red" Then
Response.Write("30.00")
End If
If Request.ServerVariables("QUERY_STRING") = "option1=l&option2=Blue" Then
Response.Write("33.00")
End If
If Request.ServerVariables("QUERY_STRING") = "option1=xl&option2=Red" Then
Response.Write("40.00")
End If
If Request.ServerVariables("QUERY_STRING") = "option1=xl&option2=Blue" Then
Response.Write("44.00")
End If
%>
calculate.asp
var strAgentString = navigator.userAgent.toLowerCase(); // The agent info from the browser
var strBrowser; // Full browser name
var strBrowserCode; // Brief browser code
var strBrowserVersion; // Browser version
var strOS; // Operating system
var strWorkString; // Work string
if (InAgentString('konqueror'))
{
strBrowser = "Konqueror";
strOS = "Linux";
}
else if (InAgentString('firefox')) {
strBrowser = "Firefox";
strBrowserCode = "FF";
}
else if (InAgentString('icab')) {
strBrowser = "iCab";
strBrowserCode = "IC";
}
else if (InAgentString('msie')) {
strBrowser = "Internet Explorer";
strBrowserCode = "IE";
}
else if (InAgentString('omniweb')) {
strBrowser = "OmniWeb";
strBrowserCode = "OW";
}
else if (InAgentString('opera')) {
strBrowser = "Opera";
strBrowserCode = "OP";
}
else if (InAgentString('safari')) {
strBrowser = "Safari";
strBrowserCode = "SA";
}
else if (InAgentString('webtv')) {
strBrowser = "WebTV";
strBrowser = "WT";
}
else if (!InAgentString('compatible'))
{
strBrowser = "Netscape Navigator";
strBrowserCode = "NN";
strBrowserVersion = strAgentString.charAt(8);
}
else
{
strBrowser = "An unknown browser";
strBrowserCode = "XX";
}
if (!strBrowserVersion) strBrowserVersion = strAgentString.charAt(intPos + strWorkString.length);
if (!strOS)
{
if (InAgentString('linux')) strOS = "Linux";
else if (InAgentString('x11')) strOS = "Unix";
else if (InAgentString('mac')) strOS = "Mac"
else if (InAgentString('win')) strOS = "Windows"
else strOS = "An unknown OS";
}
function InAgentString(string) {
intPos = strAgentString.indexOf(string) + 1;
strWorkString = string;
return intPos;
}
function GetXmlHttpObject() {
var xmlHttp=null
if (navigator.userAgent.indexOf("Opera")>=0)
{
xmlHttp=new XMLHttpRequest()
return xmlHttp
}
if (navigator.userAgent.indexOf("MSIE")>=0)
{
var strName="Msxml2.xmlHttp"
if (navigator.appVersion.indexOf("MSIE 5.5")>=0)
{
strName="Microsoft.xmlHttp"
}
try
{
xmlHttp=new ActiveXObject(strName)
return xmlHttp
}
catch(e)
{
alert("Error. Scripting for ActiveX might be disabled")
return
}
}
if (navigator.userAgent.indexOf("Mozilla")>=0)
{
xmlHttp=new XMLHttpRequest()
return xmlHttp
}
}
function count() {
stroption1 = document.calc.option1.value
stroption2 = document.calc.option2.value
var xmlHttp;
xmlHttp = GetXmlHttpObject();
xmlHttp.onreadystatechange=function()
{
if(xmlHttp.readyState==4)
{
total("ValidationResult", xmlHttp.responseText);
results("ValidationResult", xmlHttp.responseText);
return xmlHttp.responseText;
}
}
var URL = "checkoptions.asp";
URL = URL + "?option1=" + stroption1;
URL = URL + "&option2=" + stroption2;
xmlHttp.open("GET",URL,true);
xmlHttp.send(null);
}
function total(strDiv, strMessage) {
if (strBrowserCode == "IE" || strBrowserCode == "FF" || strBrowserCode == "NN" || strBrowserCode ==
"OP" || strBrowserCode == "SA")
{
document.getElementById(strDiv).innerHTML=strMessage;
document.calc.total.value=strMessage;
}
return true;
}
function results(strDiv, strMessage) {
if (document.calc.total.value == "10.00")
{
document.getElementById(strDiv).innerHTML=strMessage;
document.calc.postage.value="1.00";
document.calc.packaging.value="1.00";
document.calc.delivery.value="1.00";
document.calc.specialdelivery.value="1.00";
document.calc.admincharge.value="1.00";
}
{
if (document.calc.total.value == "11.00")
{
document.getElementById(strDiv).innerHTML=strMessage;
document.calc.postage.value="2.00";
document.calc.packaging.value="2.00";
document.calc.delivery.value="2.00";
document.calc.specialdelivery.value="2.00";
document.calc.admincharge.value="2.00";
}
{
if (document.calc.total.value == "20.00")
{
document.getElementById(strDiv).innerHTML=strMessage;
document.calc.postage.value="3.00";
document.calc.packaging.value="3.00";
document.calc.delivery.value="3.00";
document.calc.specialdelivery.value="3.00";
document.calc.admincharge.value="3.00";
}
{
if (document.calc.total.value == "22.00")
{
document.getElementById(strDiv).innerHTML=strMessage;
document.calc.postage.value="4.00";
document.calc.packaging.value="4.00";
document.calc.delivery.value="4.00";
document.calc.specialdelivery.value="4.00";
document.calc.admincharge.value="4.00";
}
{
if (document.calc.total.value == "30.00")
{
document.getElementById(strDiv).innerHTML=strMessage;
document.calc.postage.value="5.00";
document.calc.packaging.value="5.00";
document.calc.delivery.value="5.00";
document.calc.specialdelivery.value="5.00";
document.calc.admincharge.value="5.00";
}
{
if (document.calc.total.value == "33.00")
{
document.getElementById(strDiv).innerHTML=strMessage;
document.calc.postage.value="6.00";
document.calc.packaging.value="6.00";
document.calc.delivery.value="6.00";
document.calc.specialdelivery.value="6.00";
document.calc.admincharge.value="6.00";
}
{
if (document.calc.total.value == "40.00")
{
document.getElementById(strDiv).innerHTML=strMessage;
document.calc.postage.value="7.00";
document.calc.packaging.value="7.00";
document.calc.delivery.value="7.00";
document.calc.specialdelivery.value="7.00";
document.calc.admincharge.value="7.00";
}
{
if (document.calc.total.value == "44.00")
{
document.getElementById(strDiv).innerHTML=strMessage;
document.calc.postage.value="8.00";
document.calc.packaging.value="8.00";
document.calc.delivery.value="8.00";
document.calc.specialdelivery.value="8.00";
document.calc.admincharge.value="8.00";
}
return true;
}
}
}
}
}
}
}
}