Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Jul 2006
    Posts
    81
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Search not working...what am i doing wrong??

    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...earch_new.html

    Code used below:

    Code:
      <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>

  • #2
    New Coder
    Join Date
    Jul 2006
    Posts
    81
    Thanks
    4
    Thanked 0 Times in 0 Posts
    Can anyone help?

    Thanks

  • #3
    New Coder
    Join Date
    Jul 2006
    Posts
    81
    Thanks
    4
    Thanked 0 Times in 0 Posts
    Been looking at this for a few days now and i'm still struggling!


  • #4
    GŁtkodierer
    Join Date
    Apr 2009
    Posts
    2,127
    Thanks
    1
    Thanked 426 Times in 424 Posts
    Well you are treating DVDS differently than the other stuff here:
    Code:
    	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
    Code:
    document.write ("<OPTION value="+arr[i]+">"+arr[i]+"</OPTION>");
    and it will work no problem.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •