0

I am having one combo box in that I need value in order by alphabetic.but problem is In that list OTHER one value need to come at last.

we can achieve this using value number arrange according to our need but it contain lot of value and using the key I did lot of process in java script so i take lot of changes to change one thing .

<select>
    <option value="Select" selected="selected">Select</option>
    <option value="147">Articles Of Association</option>
    <option value="135">Birth Certificate</option>
    <option value="132">Drivers License</option>
    <option value="145">Memorandum Of Articles</option>
    <option value="141">Others</option>
    <option value="148">Partnership Agreement</option>
    <option value="131">Passport</option>
</select>

so using script we can push the OTHER VALUE TO LAST in the list.

joker
  • 982
  • 9
  • 23
Nanda
  • 81
  • 2
  • 9
  • If your using jquery you can just create the list aplhabetically, then use $('select').append(''); – Theodore Enderby Mar 20 '14 at 04:24
  • I found the answer. $('select[name="NameOfDropDown"] option:eq(4)').insertAfter($('select[name="NameOfDropDown"] option:eq(6)')); – Nanda Mar 20 '14 at 04:29
  • That sounds like a complicated way to do it, unless I'm unclear what your doing. You should look at Durgaprasad Budhwani's answer – Theodore Enderby Mar 20 '14 at 04:31

2 Answers2

4
$("#list option").filter(function(){
    return $(this).text()==='Others'
}).appendTo("#list")

http://jsfiddle.net/SxtnF/

aquinas
  • 23,318
  • 5
  • 58
  • 81
1

When you have created your list, like

<select id="mycombobox">
    <option value=" selected="selected">Select</option>
    <option value="147">Articles Of Association</option>
    <option value="135">Birth Certificate</option>
    <option value="132">Drivers License</option>
    <option value="145">Memorandum Of Articles</option>
    <option value="141">Others</option>
    <option value="148">Partnership Agreement</option>
    <option value="131">Passport</option>
</select>

At last, try to add Other like

$("#mycombobox").append('<option value="other">' + Other +'</option>');

This will solve your problem. Hope this will help you out.