Asked  7 Months ago    Answers:  5   Viewed   22 times

How can I get the selected value of a dropdown box using jQuery?
I tried using

var value = $('#dropDownId').val();


var value = $('select#dropDownId option:selected').val();

but both return an empty string.



For single select dom elements, to get the currently selected value:


To get the currently selected text:

$('#dropDownId :selected').text();
Tuesday, June 1, 2021
answered 7 Months ago

That can be achieved real easily by listening events. You could make the color red for example by adding class and removing class to autocomplete. I think you can accomplish this yourself with a little bit of effort.

select: function( event, ui ) {
    var terms = split( this.value );
    if(terms.length <= 2) { 
        // remove the current input
        // add the selected item
        terms.push( ui.item.value );
        // add placeholder to get the comma-and-space at the end
        terms.push( "" );
        this.value = terms.join( ", " );
        return false;
    } else {
        var last = terms.pop();
        $(this).val(this.value.substr(0, this.value.length - last.length - 2)); // removes text from input
        $(this).effect("highlight", {}, 1000);
        $("#warnings").html("<span style='color:red;'>Max people reached</span>");
        return false;

P.S I also think one of these plugins could be suitable thanks to google:


    Looks nice in my opinion:

    Demo tokenizing Autocomplete Plugin

    Click link to view live demo.


  3. Facebook style JQuery autocomplete plugin
Wednesday, March 31, 2021
answered 9 Months ago

Try this:

private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
    ComboBox cmb = (ComboBox)sender;
    int selectedIndex = cmb.SelectedIndex;
    int selectedValue = (int)cmb.SelectedValue;

    ComboboxItem selectedCar = (ComboboxItem)cmb.SelectedItem;
    MessageBox.Show(String.Format("Index: [{0}] CarName={1}; Value={2}", selectedIndex, selectedCar.Text, selecteVal));        
Thursday, June 10, 2021
answered 6 Months ago

Step 1: Take a NSString variable in your appDelegate.

Step 2: create instance of appDelegate in your both view were your want to set value and get value as following.

yourApplicationDelegate *appDelegate;

Step 3: init appDelgate in implementation file as following

appDelegate = [[UIApplication sharedApplication] delegate];

after this statement you can use the string variable from both view controller you declared in appDelegate of you application.

That's it. now you can assign value from first view and access it in second view.

Saturday, July 31, 2021
answered 4 Months ago

Use the position option to align the top of the dialog with the top of the window (plus a pixel or percent offset).

This should center the dialog horizontally and position it 150 pixels from the top.

    autoOpen: false,
    width: 630,
    position: { my: 'top', at: 'top+150' },
    modal: true,
    resizable: false,
    closeOnEscape: false

Older versions of jQuery UI used an array containing an [x,y] coordinate pair in pixel offset from left, top corner of viewport (e.g. [350,100]).

var dialogWidth = 630;
    // ...
    width: dialogWidth,
    position: [($(window).width() / 2) - (dialogWidth / 2), 150],
    // ...
Sunday, August 8, 2021
answered 4 Months ago
Only authorized users can answer the question. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :