Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3695666
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T04:38:43+00:00 2026-05-19T04:38:43+00:00

I have a multiple select field and a jquery function that checks for a

  • 0

I have a multiple select field and a jquery function that checks for a change in the select. the function looks for the value “Other”, and if it’s selected then displays an extra text field.

This is all working fine in chrome and FF, but for some reason IE throws an error on the indexOf function “Object doesn’t support this property or method”.

Any help would be much appreciated.

Here’s the code:

EDIT:
Remember that this code actually works in chrome and FF. Is only IE that is throwing the error…

<select name="test" multiple="multiple" id="test">
 <option value="one">one</option>
 <option value="two">two</option>
 <option selected="selected" value="Other">Other</option>
</select>
<input name="Name_Other" type="text" id="Name_Other" class="OtherDisplay" />


$.toggleOther = function (dd, txtOther) {
        if ($(dd).val() == null || $(dd).val().indexOf("Other") != 1) 
            $(txtOther).hide();

        $(dd).change(function () {
            var sel = $(this).val();
            if (sel != null && sel.indexOf("Other") != -1) { 
                $(txtOther).show();
            }
            else {
                $(txtOther).hide();
            }
        });
    }

$.toggleOther("#test", ".OtherDisplay");
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T04:38:44+00:00Added an answer on May 19, 2026 at 4:38 am
    $.toggleOther = function (dd, txtOther) {
            dd  =  $(dd);
            txtOther = $(txtOther);
    
            dd.change(function  () {
                var toggleBool = false;
                var sel  =  $.each($(this).val(), function(i,e){
                    if (e.indexOf("Other")!=-1) toggleBool=true;
                });
                txtOther.toggle(toggleBool);
            }).change();
        };
    
    $.toggleOther("#test", ".OtherDisplay");
    

    the code is a little shorter than the original, and a little more powerful

    this checks if any of the selected items are “Other” and if so, shows the Other text box. You see, your select box is a multiselect, so .val() returns an array (even if only one item is selected, see the docs), so we simply iterate through the array and check if any of them are the “Other” field.

    alternatively, if you wanted to check if only the Other field was selected, you could replace the $.each with a simple array length check and then put the same conditional in.

    lastly, if you wanted to make the code really flexible, and work for multiselects and not multiselects, just check what type of object .val() returns, so your code handles both stings and arrays appropriately (see the .val() docs).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this multiple select: <select id=sel_dest name=dest_var[] multiple disabled=disabled size=10> <option value= selected>Destinatario</option>
I have a select field in a form that allows you to select multiple
I have a multiple selection SELECT field which I don't want the end user
I have multiple selects: <select id=one> <option value=1>one</option> <option value=2>two</option> <option value=3>three</option> </select> <select
Which command will executed first,If a stored procedure have individual multiple select commands;
I have multiple classes that all derive from a base class, now some of
I have multiple threads (C# application running on IIS) running that all need to
I have a select options form fields setup like below: <select name=options[] multiple=multiple> <option
I have a table that has two columns, ID and Value. For this example
In MySQL table, I have a field called Tag, which may include multiple comma-delimited

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.