...

View Full Version : Search not working...what am i doing wrong??



Wardy118
05-20-2009, 09:58 AM
Hi everyone,

Been looking at this for a while now but can't see what I have done wrong.

I have built a shop search for another site we use which sells car parts and i'm trying to use a similar search for a dvd/books website.

I have changed some of the arrays etc and the first two options Accessories and Books work fine but for some reason the third option DVDS just won't load correctly.

Can anyone see what i'm doing wrong because it's driving me crazy!!

The search can be seen here: http://www.crushedice-ebayshopdesign.co.uk/car_parts_warehouse/images/ebay/classic_audio_books/search_new.html

Code used below:



<script type="text/javascript">
vehicle = new Array ("ACCESSORIES","BOOKS","DVDS");

ACCESSORIES = new Array("ACCESSORIES CDS","CDS", "ACCESSORIES DVDS", "DVDS");
BOOKS = new Array("BOOKS FICTION","FICTION", "BOOKS NON-FICTION", "NON-FICTION");
DVDS = new Array("FILMS DISNEY","DISNEY","FILMS COMEDY", "COMEDY");

function writeresults(selectname)
{
var arr = selectname;
var k=arr.length;
for (i=0; i<k; i++)
{
if (arr[i] == "DVDS")
{
document.write ("<OPTION value=\"\">"+arr[i]+"</OPTION>");
}
else
{
document.write ("<OPTION value="+arr[i]+">"+arr[i]+"</OPTION>");
}
}
}

function writenow(selectedoption)
{
var opt = selectedoption;
var optarray = window[opt]
var frm1 = document.sideForm;
frm1.model.disabled=(frm1.vehicle.selectedIndex==0);
frm1.model.selectedIndex = 0;
frm1.model.length = 1;
count=1
if(frm1.vehicle.selectedIndex > 0) for(i=0;i<optarray.length;i=i+2)
{
frm1.model.options[count] = new Option(optarray[i+1],optarray[i]);
count++
}}
</script>

Wardy118
05-20-2009, 05:25 PM
Can anyone help?

Thanks

Wardy118
05-23-2009, 12:14 PM
Been looking at this for a few days now and i'm still struggling!

:(

venegal
05-23-2009, 12:52 PM
Well you are treating DVDS differently than the other stuff here:

if (arr[i] == "DVDS")
{
document.write ("<OPTION value=\"\">"+arr[i]+"</OPTION>");
}
else
{
document.write ("<OPTION value="+arr[i]+">"+arr[i]+"</OPTION>");
}

Don't know why you decided to do that, but it's causing the problem. Change that to just

document.write ("<OPTION value="+arr[i]+">"+arr[i]+"</OPTION>");
and it will work no problem.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum