hi,
can anyone work out why i can't get an output from the form?
i don't recieve an error message so i'm finding it difficult to work out.
thanks.
// form.asp
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"<html>
<head>
<script language="JavaScript" type="text/javascript" src="calculate.js"></script>
</head>
<body>
<form name="calc" method="get">
<div id="ValidationResult" style="visibility: hidden;">Result</div>
<p> </p>
<table width="608" border="1" cellpadding="3" cellspacing="0" bordercolor="#CCCCCC">
<tr>
<td width="45%" align="center"><table border="0" cellspacing="0" cellpadding="0">
<tr>
<td valign="top"><table width="131" height="142" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="50%" height="30" valign="top"><div align="center"><strong>column 1 </strong></div></td>
</tr>
<tr>
<td width="50%" valign="top"><div align="center">
<input name="option1" type="radio" value="10">
£10</div></td>
</tr>
<tr>
<td valign="top"><div align="center">
<input name="option1" type="radio" value="20">
£20</div></td>
</tr>
<tr>
<td width="50%" valign="top"><div align="center">
<input name="option1" type="radio" value="30">
£30</div></td>
</tr>
<tr>
<td valign="top"><div align="center">
<input name="option1" type="radio" value="40">
£40</div></td>
</tr>
</table></td>
<td valign="top"><table width="131" height="142" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="50%" height="30" valign="top"><div align="center"><strong>column 2 </strong></div></td>
</tr>
<tr>
<td width="50%" valign="top"><div align="center">
<input name="option2" type="radio" value="Yes">
Yes</div></td>
</tr>
<tr>
<td valign="top"><div align="center">
<input name="option2" type="radio" value="No">
No</div></td>
</tr>
</table></td>
</tr>
</table></td>
<td width="55%" align="center"><p><strong>Annual:</strong>
<input name="annual" type="text">
</p>
<p><strong>Monthly:</strong>
<input name="monthly" type="text">
</p></td>
</tr>
</table>
<table width="439" border="0" cellpadding="3">
<tr>
<td width="421"><div align="right">
<input type="button" onClick="count()" value="Calculate">
<input type="reset" value="Reset">
</div></td>
</tr>
</table>
<p> </p>
</form>
</body>
</html>
// calculate.js
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() {
// Collect FORM fields
stroption1 = document.calc.option1.value
stroption2 = document.calc.option2.value
// Send/recv
var xmlHttp;
xmlHttp = GetXmlHttpObject();
xmlHttp.onreadystatechange=function()
{
if(xmlHttp.readyState==4)
{
annual("ValidationResult", xmlHttp.responseText);
monthly("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 annual(strDiv, strMessage) {
if (strBrowserCode == "IE" || strBrowserCode == "FF" || strBrowserCode == "NN" || strBrowserCode == "OP" || strBrowserCode == "SA")
{
document.getElementById(strDiv).innerHTML=strMessage;
document.calc.annual.value=strMessage;
}
return true;
}
function monthly(strDiv, strMessage) {
if (document.calc.annual.value == "10")
{
document.getElementById(strDiv).innerHTML=strMessage;
document.calc.monthly.value="1000";
}
{
if (document.calc.annual.value == "20")
{
document.getElementById(strDiv).innerHTML=strMessage;
document.calc.monthly.value="2000";
}
{
if (document.calc.annual.value == "30")
{
document.getElementById(strDiv).innerHTML=strMessage;
document.calc.monthly.value="3000";
}
{
if (document.calc.annual.value == "40")
{
document.getElementById(strDiv).innerHTML=strMessage;
document.calc.monthly.value="4000";
}
{
if (document.calc.annual.value == "50")
{
document.getElementById(strDiv).innerHTML=strMessage;
document.calc.monthly.value="5000";
}
{
if (document.calc.annual.value == "60")
{
document.getElementById(strDiv).innerHTML=strMessage;
document.calc.monthly.value="6000";
}
{
if (document.calc.annual.value == "70")
{
document.getElementById(strDiv).innerHTML=strMessage;
document.calc.monthly.value="7000";
}
{
if (document.calc.annual.value == "80")
{
document.getElementById(strDiv).innerHTML=strMessage;
document.calc.monthly.value="8000";
}
return true;
}
}
}
}
}
}
}
}
// checkoptions.asp
<%
If Request.Querystring("option1") = "10" AND Request.Querystring("option5") = "No" Then
Response.Write("10")
End If
If Request.Querystring("option1") = "10" AND Request.Querystring("option6") = "Yes" Then
Response.Write("20")
End If
If Request.Querystring("option2") = "20" AND Request.Querystring("option5") = "No" Then
Response.Write("30")
End If
If Request.Querystring("option2") = "20" AND Request.Querystring("option6") = "Yes" Then
Response.Write("40")
End If
If Request.Querystring("option3") = "30" AND Request.Querystring("option5") = "No" Then
Response.Write("50")
End If
If Request.Querystring("option3") = "30" AND Request.Querystring("option6") = "Yes" Then
Response.Write("60")
End If
If Request.Querystring("option4") = "40" AND Request.Querystring("option5") = "No" Then
Response.Write("70")
End If
If Request.Querystring("option4") = "40" AND Request.Querystring("option6") = "Yes" Then
Response.Write("80")
End If
%>
can anyone work out why i can't get an output from the form?
i don't recieve an error message so i'm finding it difficult to work out.
thanks.
// form.asp
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"<html>
<head>
<script language="JavaScript" type="text/javascript" src="calculate.js"></script>
</head>
<body>
<form name="calc" method="get">
<div id="ValidationResult" style="visibility: hidden;">Result</div>
<p> </p>
<table width="608" border="1" cellpadding="3" cellspacing="0" bordercolor="#CCCCCC">
<tr>
<td width="45%" align="center"><table border="0" cellspacing="0" cellpadding="0">
<tr>
<td valign="top"><table width="131" height="142" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="50%" height="30" valign="top"><div align="center"><strong>column 1 </strong></div></td>
</tr>
<tr>
<td width="50%" valign="top"><div align="center">
<input name="option1" type="radio" value="10">
£10</div></td>
</tr>
<tr>
<td valign="top"><div align="center">
<input name="option1" type="radio" value="20">
£20</div></td>
</tr>
<tr>
<td width="50%" valign="top"><div align="center">
<input name="option1" type="radio" value="30">
£30</div></td>
</tr>
<tr>
<td valign="top"><div align="center">
<input name="option1" type="radio" value="40">
£40</div></td>
</tr>
</table></td>
<td valign="top"><table width="131" height="142" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="50%" height="30" valign="top"><div align="center"><strong>column 2 </strong></div></td>
</tr>
<tr>
<td width="50%" valign="top"><div align="center">
<input name="option2" type="radio" value="Yes">
Yes</div></td>
</tr>
<tr>
<td valign="top"><div align="center">
<input name="option2" type="radio" value="No">
No</div></td>
</tr>
</table></td>
</tr>
</table></td>
<td width="55%" align="center"><p><strong>Annual:</strong>
<input name="annual" type="text">
</p>
<p><strong>Monthly:</strong>
<input name="monthly" type="text">
</p></td>
</tr>
</table>
<table width="439" border="0" cellpadding="3">
<tr>
<td width="421"><div align="right">
<input type="button" onClick="count()" value="Calculate">
<input type="reset" value="Reset">
</div></td>
</tr>
</table>
<p> </p>
</form>
</body>
</html>
// calculate.js
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() {
// Collect FORM fields
stroption1 = document.calc.option1.value
stroption2 = document.calc.option2.value
// Send/recv
var xmlHttp;
xmlHttp = GetXmlHttpObject();
xmlHttp.onreadystatechange=function()
{
if(xmlHttp.readyState==4)
{
annual("ValidationResult", xmlHttp.responseText);
monthly("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 annual(strDiv, strMessage) {
if (strBrowserCode == "IE" || strBrowserCode == "FF" || strBrowserCode == "NN" || strBrowserCode == "OP" || strBrowserCode == "SA")
{
document.getElementById(strDiv).innerHTML=strMessage;
document.calc.annual.value=strMessage;
}
return true;
}
function monthly(strDiv, strMessage) {
if (document.calc.annual.value == "10")
{
document.getElementById(strDiv).innerHTML=strMessage;
document.calc.monthly.value="1000";
}
{
if (document.calc.annual.value == "20")
{
document.getElementById(strDiv).innerHTML=strMessage;
document.calc.monthly.value="2000";
}
{
if (document.calc.annual.value == "30")
{
document.getElementById(strDiv).innerHTML=strMessage;
document.calc.monthly.value="3000";
}
{
if (document.calc.annual.value == "40")
{
document.getElementById(strDiv).innerHTML=strMessage;
document.calc.monthly.value="4000";
}
{
if (document.calc.annual.value == "50")
{
document.getElementById(strDiv).innerHTML=strMessage;
document.calc.monthly.value="5000";
}
{
if (document.calc.annual.value == "60")
{
document.getElementById(strDiv).innerHTML=strMessage;
document.calc.monthly.value="6000";
}
{
if (document.calc.annual.value == "70")
{
document.getElementById(strDiv).innerHTML=strMessage;
document.calc.monthly.value="7000";
}
{
if (document.calc.annual.value == "80")
{
document.getElementById(strDiv).innerHTML=strMessage;
document.calc.monthly.value="8000";
}
return true;
}
}
}
}
}
}
}
}
// checkoptions.asp
<%
If Request.Querystring("option1") = "10" AND Request.Querystring("option5") = "No" Then
Response.Write("10")
End If
If Request.Querystring("option1") = "10" AND Request.Querystring("option6") = "Yes" Then
Response.Write("20")
End If
If Request.Querystring("option2") = "20" AND Request.Querystring("option5") = "No" Then
Response.Write("30")
End If
If Request.Querystring("option2") = "20" AND Request.Querystring("option6") = "Yes" Then
Response.Write("40")
End If
If Request.Querystring("option3") = "30" AND Request.Querystring("option5") = "No" Then
Response.Write("50")
End If
If Request.Querystring("option3") = "30" AND Request.Querystring("option6") = "Yes" Then
Response.Write("60")
End If
If Request.Querystring("option4") = "40" AND Request.Querystring("option5") = "No" Then
Response.Write("70")
End If
If Request.Querystring("option4") = "40" AND Request.Querystring("option6") = "Yes" Then
Response.Write("80")
End If
%>