Forum Moderators: open
Having a problem ascertaining the correct value for the first column of the array in the sample below showing up in the action commands at the bottom of the script.
Any idea what I need to put in place of the X in the "window.location"? I've worked out the 2nd through 4th position, but have no clue how to get the 1st position to be imbedded into the URL. For example if I click on the Analytical option within the METERS menu list, how do I get the 657 value to be included?
Thanks in advance
Tony
categorys=new Array(null
,new Array("999","TYPE","BRAND","PRODUCT")
,new Array("657","device","METERS","Analytical")
,new Array("484","device","METERS","AirFlow")
);
//level variable
var level=0;
function loadSubGroups() { document.form.product.options[i]=new Option(product_array[i][0]); function viewProduct(type){ [1][edited by: YankeeRoo at 1:11 pm (utc) on May 17, 2009]
for (i = document.form.product.options.length; i >= 0; i--) {
document.form.product.options[i] = null;
}
var brand_name = document.form.brand.value;
var product_j=0
var product_array =new Array();
for(var i=1;i<categorys.length;i++){
if(categorys[i][2]==brand_name){
if(categorys[i]== 'device'){
//Search if the item exists already!
product_flag = true;
for(var m=0;m<product_array.length;m++){
if(product_array[m][0] == categorys[i][3]){
product_flag = false;
}
}
if(product_flag){
product_array[product_j]=new Array(categorys[i][3],categorys[i][3]);
product_j++;
}
}
}
}
product_array.sort();
for( var i=0;i<product_array.length;i++){
document.form.product.options[i].value=product_array[i][1];
}
}
if(type == 'product'){
window.location="http://www.yankeeroo.com/store/home.php?cat="+document.form.X.value;
}
}
categorys = [
null
,["999","TYPE","BRAND","PRODUCT"]
,["657","device","METERS","Analytical"]
,["484","device","METERS","AirFlow"]
];
In other words, categorys[2] gets the array ("657","device","METERS","Analytical"), and then [0] gets the first item in that array.
I think you'll want to correct this code:
if (categorys[i] == 'device') {
if (categorys[i][1] == 'device') {
[edited by: Fotiman at 2:29 pm (utc) on May 18, 2009]
What do I need to replace the '+document.form.battery.value;" with in order to make this work?
I'm expecting the URL of http://www.example.com/store/home.php?cat=657 to be passed through
Thanks mate
categorys = [
null
,["657","device","METERS","Analytical Meters"]
,["484","device","METERS","Air Flow Meters"]
,["580","device","METERS","Calibrators"]
];
//level variable
var level=0;
function loadSubGroups() {
for (i = document.form.product.options.length; i >= 0; i--) { document.form.product.options[i]=new Option(product_array[i][0]); } //battery product brand category_id [1][edited by: whoisgregg at 1:03 pm (utc) on May 19, 2009]
document.form.product.options[i] = null;
}
var brand_name = document.form.brand.value;
var product_j=0
var product_array =[];
for(var i=1;i<categorys.length;i++){
if(categorys[i][2]==brand_name){
if(categorys[i]== 'device'){
//Search if the item exists already!
product_flag = true;
for(var m=0;m<product_array.length;m++){
if(product_array[m][0] == categorys[i][3]){
product_flag = false;
}
}
if(product_flag){
product_array[product_j]=[categorys[i][3],categorys[i][3]);
product_j++;
}
}
}
}
product_array.sort();
for( var i=0;i<product_array.length;i++){
document.form.product.options[i].value=product_array[i][1];
}
function viewProduct(type){
if(type == 'product'){
window.location="http://www.example.com/store/home.php?cat="+document.form.battery.value;
}
}
[edit reason] Whoops, no URLs please. Use "example.com" :) [/edit]
Can someone tell me in laymans terms exactly what I need to do? (Im not a web programmer)
Heres the HTML.......
<form name=form>
<table width=100%>
<tr>
<td valign=top width="25">
</td>
<td valign=top width="175">
<div align=left><b>Category</b></div>
<select name=brand onClick="loadSubGroups();" size=9 style="font-family: verdana; font-size: 11px">
<!-- Enter in selections and values for the BRAND colum -->
<option value="ACCESSORIES">Accessories</option>
<option value="ASSEMBLY">Assembly & Parts</option>
<option value="BATTERY">Batteries</option>
<option value="CHARGERS">Battery Chargers</option>
<option value="METERS">Measurement Meters</option>
<option value="POWER">Power Products</option>
<option value="TORCH">Torches</option>
</select>
</td>
<td width="200">
<div align=left><b>Sub Category</b></div>
<select name=product onClick="viewProduct('product');" size=9 style="font-family: verdana; font-size: 11px"></select>
</td>
<td>
</td>
</tr>
</table>
</form>