Home & blog  /  Tag: select  /

Using Dropdown as a fancy form field

posted: 09 Aug '11 08:31 tags: dropdown, select, form

Not before time, I've updated my Dropdown plugin for jQuery. It now supports a new 'form field' mode, meaning you can use Dropdown as a fancy alternative to a , it submits a value to the server once the form is submitted.

It does this by creating a hidden field, whose value is updated every time an 'option' in the dropdown is selected. The name of this hidden field (i.e. the name of the value that should be sent to the server on submit) is denoted a parameter at set-up. Here's an example of using Dropdown in form field mode:

1new Dropdown({

2     mode: 'form',

3     data: [{val: 1, text: 'dog'}, {val: 2, text: 'cat'}, {val: 3, text: 'platipus'}],

4     startText: 'Select an option...',

5     fieldName: 'animal'

6});

Head over here to download, get usage info or view a demo.

post a comment

jQuery drop-down selector

posted: 11 Jul '10 13:09 tags: select, drop-down, navigation

UI / UX developers have long wished the built-in , except with links, not options, and allowing you to specify the behaviour of each link (callback? disabled?) and precisely how the drop-down looks.

Head over here to download, get usage info or view a demo.

You call it by running dropdown(linkData), where 'linkData' is an array containing objects that hold data about each link, like so:

1dropdown([

2     {url: 'http://www.yahoo.co.uk', text: 'Yahoo!'],

3     {text: 'Bing', click: function() {

4         alert("Sorry - we're not going to Bing right now");

5     }},

6     {url: 'http://www.google.co.uk', text: 'Google', disabled: true}

7]);

As with everything I write, it's just one file. No dependent HTML or CSS - everything's DOM-scripted by the scirpt and styled within it, too.

post a comment