hi,
i would like to be able to return more than one value to the page once the two dropdown menus have been selected.
at the moment i am only able to return one.
can anyone help?
any help would be greatly appreciated!
many thanks.
here is the code so far:
// 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>
<div id="ValidationResult">Result</div>
<form name="calc" method="post">
<table width="439" border="0" cellpadding="3">
<tr>
<th width="30%" align="center">Amount</th>
<th align="center">Color</th>
</tr>
<tr>
<td align="center"><select name="option1" onClick="count()">
<option value=""></option>
<option value="10">£10</option>
<option value="20">£20</option>
<option value="30">£30</option>
<option value="40">£40</option>
</select>
</td>
<td width="40%" align="center"><select name="option2" onClick="count()">
<option value=""></option>
<option value="Red">Red</option>
<option value="Blue">Blue</option>
</select>
</td>
</tr>
</table>
<table width="439" border="0" cellpadding="3">
<tr>
<td width="236"></td>
<td width="276"><div align="right"><strong>Premium:</strong>
<input name="pay" type="text">
</div></td>
</tr>
<tr>
<td colspan="2"><div align="right">
<input type="reset" value="Reset">
</div></td>
</tr>
</table>
</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 check(regex,current){
re = new RegExp(regex);
for(i = 0; i < document.forms[0].elements.length; i++) {
elm = document.forms[0].elements;
if (elm.type == 'checkbox') {
if (re.test(elm.name)) {
elm.checked = false;
}
}
}
current.checked = true;
}
function count() {
// Collect FORM fields
stroption1 = document.calc.option1.options[document.calc.option1.selectedIndex].value
stroption2 = document.calc.option2.options[document.calc.option2.selectedIndex].value
// Send/recv
var xmlHttp;
xmlHttp = GetXmlHttpObject();
xmlHttp.onreadystatechange=function()
{
if(xmlHttp.readyState==4)
{
pay("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 pay(strDiv, strMessage) {
if (strBrowserCode == "IE" || strBrowserCode == "FF" || strBrowserCode == "NN" || strBrowserCode == "OP" || strBrowserCode == "SA")
{
document.getElementById(strDiv).innerHTML=strMessage;
document.calc.pay.value=strMessage;
}
return true;
}
// checkoptions.asp
<%
If Request.Querystring("option1") = "10" AND Request.Querystring("option2") = "Red" Then
Response.Write("10 Red")
End If
If Request.Querystring("option1") = "10" AND Request.Querystring("option2") = "Blue" Then
Response.Write("10 Blue")
End If
If Request.Querystring("option1") = "20" AND Request.Querystring("option2") = "Red" Then
Response.Write("20 Red")
End If
If Request.Querystring("option1") = "20" AND Request.Querystring("option2") = "Blue" Then
Response.Write("20 Blue")
End If
If Request.Querystring("option1") = "30" AND Request.Querystring("option2") = "Red" Then
Response.Write("30 Red")
End If
If Request.Querystring("option1") = "30" AND Request.Querystring("option2") = "Blue" Then
Response.Write("30 Blue")
End If
If Request.Querystring("option1") = "40" AND Request.Querystring("option2") = "Red" Then
Response.Write("40 Red")
End If
If Request.Querystring("option1") = "40" AND Request.Querystring("option2") = "Blue" Then
Response.Write("40 Blue")
End If
%>
i would like to be able to return more than one value to the page once the two dropdown menus have been selected.
at the moment i am only able to return one.
can anyone help?
any help would be greatly appreciated!
many thanks.
here is the code so far:
// 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>
<div id="ValidationResult">Result</div>
<form name="calc" method="post">
<table width="439" border="0" cellpadding="3">
<tr>
<th width="30%" align="center">Amount</th>
<th align="center">Color</th>
</tr>
<tr>
<td align="center"><select name="option1" onClick="count()">
<option value=""></option>
<option value="10">£10</option>
<option value="20">£20</option>
<option value="30">£30</option>
<option value="40">£40</option>
</select>
</td>
<td width="40%" align="center"><select name="option2" onClick="count()">
<option value=""></option>
<option value="Red">Red</option>
<option value="Blue">Blue</option>
</select>
</td>
</tr>
</table>
<table width="439" border="0" cellpadding="3">
<tr>
<td width="236"></td>
<td width="276"><div align="right"><strong>Premium:</strong>
<input name="pay" type="text">
</div></td>
</tr>
<tr>
<td colspan="2"><div align="right">
<input type="reset" value="Reset">
</div></td>
</tr>
</table>
</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 check(regex,current){
re = new RegExp(regex);
for(i = 0; i < document.forms[0].elements.length; i++) {
elm = document.forms[0].elements;
if (elm.type == 'checkbox') {
if (re.test(elm.name)) {
elm.checked = false;
}
}
}
current.checked = true;
}
function count() {
// Collect FORM fields
stroption1 = document.calc.option1.options[document.calc.option1.selectedIndex].value
stroption2 = document.calc.option2.options[document.calc.option2.selectedIndex].value
// Send/recv
var xmlHttp;
xmlHttp = GetXmlHttpObject();
xmlHttp.onreadystatechange=function()
{
if(xmlHttp.readyState==4)
{
pay("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 pay(strDiv, strMessage) {
if (strBrowserCode == "IE" || strBrowserCode == "FF" || strBrowserCode == "NN" || strBrowserCode == "OP" || strBrowserCode == "SA")
{
document.getElementById(strDiv).innerHTML=strMessage;
document.calc.pay.value=strMessage;
}
return true;
}
// checkoptions.asp
<%
If Request.Querystring("option1") = "10" AND Request.Querystring("option2") = "Red" Then
Response.Write("10 Red")
End If
If Request.Querystring("option1") = "10" AND Request.Querystring("option2") = "Blue" Then
Response.Write("10 Blue")
End If
If Request.Querystring("option1") = "20" AND Request.Querystring("option2") = "Red" Then
Response.Write("20 Red")
End If
If Request.Querystring("option1") = "20" AND Request.Querystring("option2") = "Blue" Then
Response.Write("20 Blue")
End If
If Request.Querystring("option1") = "30" AND Request.Querystring("option2") = "Red" Then
Response.Write("30 Red")
End If
If Request.Querystring("option1") = "30" AND Request.Querystring("option2") = "Blue" Then
Response.Write("30 Blue")
End If
If Request.Querystring("option1") = "40" AND Request.Querystring("option2") = "Red" Then
Response.Write("40 Red")
End If
If Request.Querystring("option1") = "40" AND Request.Querystring("option2") = "Blue" Then
Response.Write("40 Blue")
End If
%>