Hello all. I have a piece of code that was written by a professional. I am trying to extract some values that are held in an array and displayed in a loop on my page.
There are Vehicle values and Price Values.
if (!goBook)
{
if (V == "*")
{
Response.Write(Price("") + " = \
");
if ((Session("ListAttributes"))
&& (Session("ListAttributes").length > 0))
{
for (var j = 0; j < Session("ListAttributes").length; j++)
{
var aa = String(Session("ListAttributes")[j][0]);
%>
<table>
<tr>
<td><% Response.Write(aa + "\
"); %> <!--Vehicle Value Displays Here--></td>
<td><% Response.Write(Price(aa)); %> <!--Price Value Displays Here--></td>
</tr>
</table>
<%
}
}
}
else
{
Response.Write(Price(V));
}
Response.End();
}
what i want to do is extract these individual values and use them throughout my page. If a piece of code to separate them is not necessary then I perhaps need some variable names which can display each individual value.
my code is below. i hope this is clear.
<%@ Language = "JavaScript" %>
<%
// $Header: /Projects/Taxi/WebBooker/WJBasp.NV/QQuote.asp 2
8/04/09 14:19 David.g $
//
Response.ContentType = "text/plain";
if (Application("WJB") == null)
{
Response.Write("?No COM object");
Response.End();
}
if ((Request.Form.Count == 0)
&& (Request.QueryString.Count == 0))
{
Response.Write("?No parameters");
Response.End();
}
var P = "";
var D = "";
var V = "";
var goBook = false;
if (Request.Form("P").Count == 1)
{
P = String(Request.Form("P"));
}
else if (Request.QueryString("P").Count == 1)
{
P = String(Request.QueryString("P"));
}
if (Request.Form("D").Count == 1)
{
D = String(Request.Form("D"));
}
else if (Request.QueryString("D").Count == 1)
{
D = String(Request.QueryString("D"));
}
if (Request.Form("V").Count == 1)
{
V = String(Request.Form("V"));
}
else if (Request.QueryString("V").Count == 1)
{
V = String(Request.QueryString("V"));
}
if (Request.Form("B").Count == 1)
{
goBook = !! Request.Form("B");
}
else if (Request.QueryString("B").Count == 1)
{
goBook = !! Request.QueryString("B");
}
if ((P == "") || (D == ""))
{
Response.Write("?Need Pickup & Dropoff");
Response.End();
}
var pal = Application("WJB").MatchAddress(P);
if (pal.count != 1)
{
Response.Write("?Need exactly one Pickup address match");
Response.End();
}
var dal = Application("WJB").MatchAddress(D);
if (dal.count != 1)
{
Response.Write("?Need exactly one Dropoff address match");
Response.End();
}
if (!Session("User"))
{
Session("User") = Application("WJB").CreateEmptyUser(Session("DefaultAC"));
}
if (!Session("User"))
{
Response.Write("?Can't login empty user");
Response.End();
}
%>
<h1 style="font-family:arial;color:#f99c08;font-size:14pt;font-weight:bold;margin-left:20px;margin-top:40px;"><%
Response.Write(P); %> to <% Response.Write(D); %></h1>
<%
var job = Session("User").CreateEmptyJob();
job.JobType = Session("DefaultJT");
job.IgnoreReferences = true;
job.PassengerName = "x";
job.PuAddress = pal.Address(0);
job.PuPostcode = pal.Postcode(0);
job.PuNgrE = pal.NgrE(0);
job.PuNgrN = pal.NgrN(0);
job.DoAddress = dal.Address(0);
job.DoPostcode = dal.Postcode(0);
job.DoNgrE = dal.NgrE(0);
job.DoNgrN = dal.NgrN(0);
[B]if (!goBook)
{
if (V == "*")
{
Response.Write(Price("") + " = \
");
if ((Session("ListAttributes"))
&& (Session("ListAttributes").length > 0))
{
for (var j = 0; j < Session("ListAttributes").length; j++)
{
var aa = String(Session("ListAttributes")[j][0]);
%>
<table>
<tr>
<td><% Response.Write(aa + "\
"); %> <!--Vehicle Displays Here--></td>
<td><% Response.Write(Price(aa)); %> <!--Price Displays Here--></td>
</tr>
</table>
<%
}
}
}
else
{
Response.Write(Price(V));
}
Response.End();
}[/B]
var VI = -1;
if ((V)
&& (V != "*"))
{
VI = MatchAttribute(V);
}
// Here to go book the job (or at least log in)
Response.ContentType = "text/html";
job.PassengerName = "";
var now = new Date();
var T = parseInt(Session("LeadTimeMins"));
T = T * 60000;
job.NominalPickupTime = now.getTime() + T;
Session("Job") = job;
Session("HasQuote") = true;
Session("LAlist") = null;
Session("LAindex") = -1;
Session("PAlist") = pal;
Session("PAindex") = 0;
Session("DAlist") = dal;
Session("DAindex") = 0;
Session("PTindex") = 0;
Session("DTindex") = 0;
Session("VAindex") = VI;
Session("PPremise") = "";
Session("InvisibleDefaultDA") = new Object();
Session("InvisibleDefaultVA") = new Object();
Response.Redirect("OneFormLogin.asp");
Response.End();
function Price(va)
{
job.VehicleAttributeCount = 0;
var vi = MatchAttribute(va);
if (vi >= 0)
{
var la = Session("ListAttributes")[vi][1];
for (var i = 0; i < la.length; i++)
{
job.SetVehicleAttribute(i, la[i]);
}
}
var q = String(job.GetQuotation());
var e = String(job.Error);
if (e != "")
{
return ("?" + e);
}
// Typical response is :
// The Cost of the Trip is <b>£87.00</b>: Fare £87.00
var cs = "The Cost of the Trip is <b>£";
if (q.search(cs) == 0)
{
q = q.substr(cs.length);
q.match(/^([\\d\\.]+)/);
return(RegExp.$1);
}
else
{
return("?Can't get price from string " + q);
}
}
function MatchAttribute(va)
{
var vi = -1;
if ((va != "")
&& (Session("ListAttributes"))
&& (Session("ListAttributes").length > 0))
{
var vv = va.toLowerCase();
for (var j = 0; j < Session("ListAttributes").length; j++)
{
var aa = String(Session("ListAttributes")[j][0]).toLowerCase();
if (vv == aa)
{
vi = j;
break;
}
}
}
return vi;
}
%>