Page 1 of 2 12 LastLast
Results 1 to 10 of 15

Thread: Drop down - sort by

  1. #1
    Join Date
    Apr 2008
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Drop down - sort by

    I'm new to web design and I'm trying find a script that will allow me to add a drop down menu that refines results within a page or subsection of the website. Something like price highest to lowest or vice versa or brand, you've all seen this on larger ecommerece websites before. If you all have any websites or files referencing this I would be very greatful.

    Thanks,
    Steve

  2. #2
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    Alright, I just whipped up a little code(if you can't you javascript but you can use php just tell me):
    Code:
    <script type="text/javascript">
    
    var abc = new Array();
    var abc = [65,46,32,99,1,"A","k"];
    abc.sort(); //sorts the array
    document.write('<select>'); // writes our select tag
    for (i=0;i<=abc.length-1;i++){ //make a forloop for each value we have in our array
    document.write('<option value="i">'+abc[i]+'</option>'); //wirte everything
    } //close forloop
    document.write('</select>'); //close select tag
    </script>
    The selected part is an array, if your using an int value, you don't need to the double quotes, otherwise include them.
    Last edited by Nile; 04-08-2008 at 10:37 PM.
    Jeremy | jfein.net

  3. #3
    Join Date
    Apr 2008
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I'm sure this helps but I don't know javascript that well so it just looks foreign to me. Where you put write everything, write what exactly? brand, price, etc.? if so how do I list it? As I said, I just don't know it that well so I'm starting from scratch on creating this part of the website. Is it possible to create this as an external javascript file for each subsection then reference it?

  4. #4
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    Alrighty:
    You put this in every you want to be sorted. Every time you copy and paste this you need to change the variables.
    Code:
    var abc = [65,46,32,99,1,"A","k"];
    Is where all your options are, so you need to change those to your needs[more info about this at the bottom of my top post].
    Everything else don't worry about it. If you want I'll make a code that'll just get all your selects on the page and make them 123abc order. But that'll take longer. So if you want that just say and I'll make it.
    Jeremy | jfein.net

  5. #5
    Join Date
    Apr 2008
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    If you can do that I would be greatful or if you know of an external site where I can see a full size example that would be great. I know I can put it together I just need to see it in action first then I can understand it all better. thanks much.

  6. #6
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    Alright, I'll make you the script. It may take over 15 minutes because atm I'm doing something else.
    Jeremy | jfein.net

  7. #7
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    Alrighty, I failed on making this. So just gimme your code so I can change everything that needs to be 123ab- afied.
    Jeremy | jfein.net

  8. #8
    Join Date
    Apr 2008
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    well that's just it I don't have anything yet. I'm in the process of designing and writing the css and html parts. Wasn't sure how to go about this function but thought if I could get a sampling then I could go from there. I tried to take a look at javascript and I started getting a headache. Is there a specific name for that type of function or form? If so I can try searching more from that I just couldn't pull any results when I was looking earlier. Thanks for your help.

  9. #9
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    I made it up completely by myself, so no. Heres an example though: http://nile.richei.net/applets/array_sort.html
    Jeremy | jfein.net

  10. #10
    Join Date
    Apr 2008
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    That's kinda what I'm looking for and maybe I'm just not familiar enough with it to know if it can be adapted to what I'm looking for.

    Here's a link to an example of what I'm looking for exactly: http://www.barbecues.com/web/catalog/ethumbs.aspx?N=103+3187827&Ns=P_Inventory|1||P_ProductName

    The section in the center that is a drop down and has "product name" in it. When you select it, it allows you to sort all items within that subsection by price ascending or descending or by brand.

    Sorry again for being so clueless on javascript.

Bookmarks

Posting Permissions

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