...

View Full Version : Help identifying variables



bshul
06-19-2008, 05:46 PM
Hello,

Im trying to find the variable names that store the selected value from the drop down menus script, so that the joinFields function can be rewritten to accept these values. Thank you for your help. Code as follows:

<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Test dynamic changes to Option objects</title>
<script language="JavaScript" type="text/JavaScript">
var i=0;
var aryAll = new Array();
// ===========================================
// EDIT HERE. This section defines everything.
// ===========================================

aryAll[i]=["Acura","Acura Model 1", "Front Seat", "1990-1999"]; i++;
aryAll[i]=["Acura","Acura Model 1", "Front Seat", "2000-2008"]; i++;
aryAll[i]=["Acura","Acura Model 1", "Back Seat", "1990-1999"]; i++;
aryAll[i]=["Acura","Acura Model 1", "Back Seat", "2000-2008"]; i++;
aryAll[i]=["Acura","Acura Model 2", "Driver's Seat", "1990-1999"]; i++;
aryAll[i]=["Acura","Acura Model 2", "Driver's Seat", "2000-2008"]; i++;
aryAll[i]=["Acura","Acura Model 2", "Passenger's Seat", "1990-1999"]; i++;
aryAll[i]=["Acura","Acura Model 2", "Passenger's Seat", "2000-2008"]; i++;
aryAll[i]=["BMW", "BMW Model 1", "Front Seat", "1980-1995"]; i++;
aryAll[i]=["BMW", "BMW Model 1", "Front Seat", "1996-2008"]; i++;
aryAll[i]=["BMW", "BMW Model 1", "Back Seat", "1980-1995"]; i++;
aryAll[i]=["BMW", "BMW Model 1", "Back Seat", "1996-2008"]; i++;
aryAll[i]=["BMW", "BMW Model 2", "Front Seat", "1980-1995"]; i++;
aryAll[i]=["BMW", "BMW Model 2", "Front Seat", "1996-2008"]; i++;
aryAll[i]=["BMW", "BMW Model 2", "Back Seat", "1980-1995"]; i++;
aryAll[i]=["BMW", "BMW Model 2", "Back Seat", "1996-2008"]; i++;
aryAll[i]=["BMW", "BMW Model 3", "Front Seat", "1980-1995"]; i++;
aryAll[i]=["BMW", "BMW Model 3", "Front Seat", "1996-2008"]; i++;
aryAll[i]=["BMW", "BMW Model 3", "Back Seat", "1980-1995"]; i++;
aryAll[i]=["BMW", "BMW Model 3", "Back Seat", "1996-2008"]; i++;
aryAll[i]=["Honda", "Honda Model 1", "Catbird Seat", "All"]; i++;
aryAll[i]=["Honda", "Honda Model 1", "Jump Seat", "All"]; i++;
aryAll[i]=["Kia", "Kia Model 1", "Left Side Seat", "All"]; i++;
aryAll[i]=["Kia", "Kia Model 1", "Right Side Seat", "All"]; i++;
aryAll[i]=["Mercedes", "Mercedes Model 1", "Front Seat", "All"]; i++;
aryAll[i]=["Mercedes", "Mercedes Model 1", "Back Seat", "All"]; i++;

// ===========================================
// END OF EDIT SECTION.
// ===========================================
function StartUp()
{
var currMake="";
var currMakeNdx=0;
for (i=0; i<aryAll.length; i++)
{
if (currMake != aryAll[i][0])
{
currMake=aryAll[i][0];
document.forms["Form01"].elements["mnuMakes"].options[currMakeNdx] = new Option();
document.forms["Form01"].elements["mnuMakes"].options[currMakeNdx].text = currMake;
currMakeNdx++;
}
}
ChangeModels();
}

function ChangeModels()
{
// Find the selected Make
var currMake=FindMake();

// Clear the previous options for the Models list
ClearModel();

// Populate Models list for this Make
var currModel="";
var currModelNdx=0;
for (i=0; i<aryAll.length; i++)
{
if (currMake == aryAll[i][0])
{
if (currModel != aryAll[i][1])
{
document.forms["Form01"].elements["mnuModels"].options[currModelNdx] = new Option();
document.forms["Form01"].elements["mnuModels"].options[currModelNdx].text = aryAll[i][1];
currModel = aryAll[i][1];
currModelNdx++;
}
}
}
ChangeSeats()
}

function ChangeSeats()
{
// Find the selected Make & Model
var currMake=FindMake();
var currModel=FindModel();

// Clear the previous options for the Seats list
ClearSeat();

// Populate Seats list for this Make & Model
var currSeat="";
var currSeatNdx=0;

for (i=0; i<aryAll.length; i++)
{
if (currMake == aryAll[i][0])
{
if (currModel == aryAll[i][1])
{
if (currSeat != aryAll[i][2])
{
document.forms["Form01"].elements["mnuSeats"].options[currSeatNdx] = new Option();
document.forms["Form01"].elements["mnuSeats"].options[currSeatNdx].text = aryAll[i][2];
currSeat = aryAll[i][2];
currSeatNdx++;
}
}
}
}
ChangeYears()
}

function ChangeYears()
{
// Find the selected Make & Model & Seats
var currMake=FindMake();
var currModel=FindModel();
var currSeat=FindSeat();

// Clear the previous options for the Years list
ClearYear();

// Populate Years list for this Make & Model & Seat
var currYear="";
var currYearNdx=0;

for (i=0; i<aryAll.length; i++)
{
if (currMake == aryAll[i][0])
{
if (currModel == aryAll[i][1])
{
if (currSeat == aryAll[i][2])
{
if (currYear != aryAll[i][3])
{
document.forms["Form01"].elements["mnuYears"].options[currYearNdx] = new Option();
document.forms["Form01"].elements["mnuYears"].options[currYearNdx].text = aryAll[i][3];
currYear = aryAll[i][3];
currYearNdx++;
}
}
}
}
}
}

function FindMake()
{
for (i=0; i<document.forms["Form01"].elements["mnuMakes"].options.length; i++)
{
if (document.forms["Form01"].elements["mnuMakes"].options[i].selected)
{
return document.forms["Form01"].elements["mnuMakes"].options[i].text;
}
}
}

function FindModel()
{
for (i=0; i<document.forms["Form01"].elements["mnuModels"].options.length; i++)
{
if (document.forms["Form01"].elements["mnuModels"].options[i].selected)
{
return document.forms["Form01"].elements["mnuModels"].options[i].text;
}
}
}

function FindSeat()
{
for (i=0; i<document.forms["Form01"].elements["mnuSeats"].options.length; i++)
{
if (document.forms["Form01"].elements["mnuSeats"].options[i].selected)
{
return document.forms["Form01"].elements["mnuSeats"].options[i].text;
}
}
}

function ClearModel()
{
document.forms["Form01"].elements["mnuModels"].options.length=0;
document.forms["Form01"].elements["mnuModels"].options[0] = new Option();
document.forms["Form01"].elements["mnuModels"].options[0].text = "Select";
ClearSeat();
}

function ClearSeat()
{
document.forms["Form01"].elements["mnuSeats"].options.length=0;
document.forms["Form01"].elements["mnuSeats"].options[0] = new Option();
document.forms["Form01"].elements["mnuSeats"].options[0].text = "Select";
ClearYear();
}

function ClearYear()
{
document.forms["Form01"].elements["mnuYears"].options.length=0;
document.forms["Form01"].elements["mnuYears"].options[0] = new Option();
document.forms["Form01"].elements["mnuYears"].options[0].text = "Select";
}

//-->
</script>
</HEAD>
<script language="JavaScript">
function joinFields( ){
fmBuy.on0.value = "For This Vehicle"
fmBuy.os0.value = 'Year:' + fmBuy.custom1.value + ' -Make:' + fmBuy.custom2.value + ' -Model:' + fmBuy.custom3.value + ' -Seat:' + fmBuy.custom4.value;
}
</script>
<body onLoad="StartUp()">

<form name="Form01">
MAKE
<select name="mnuMakes" onChange="ChangeModels()">
<option selected>Select</option>
</select>

<br>
MODEL
<select name="mnuModels" onChange="ChangeSeats()">
<option selected>Select</option>
</select>
<br>
SEAT
<select name="mnuSeats" onChange="ChangeYears()">
<option selected>Select</option>
</select>
<br>
YEAR
<select name="mnuYears">
<option selected>Select</option>
</select>
</form>

<form action="https://www.paypal.com/cgi-bin/webscr" method="post" name="fmBuy" //onSubmit="joinFields( )">

<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="add" value="1">
<input type="hidden" name="business" value="rooldgold@yahoo.com">
<input type="hidden" name="item_name" value="Seat Belt Extender">
<input type="hidden" name="amount" value="28.00">
<input type="hidden" name="no_note" value="1">
<input type="hidden" name="on0" value="1">
<input type="hidden" name="os0" value="1">
<input type="hidden" name="os1" value="1">
<input type="hidden" name="currency_code" value="USD">
</script>
<p style="background: yellow; color: red ">


QUANTITY
<select name="quantity">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
</select>
</form>
</body>
</html>

Philip M
06-19-2008, 06:15 PM
var aryAll = new Array();
// ===========================================
// EDIT HERE. This section defines everything.
// ===========================================



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum