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 9146343
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T10:43:41+00:00 2026-06-17T10:43:41+00:00

I have a SelectList representing a delivery type for an order. The delivery type

  • 0

I have a SelectList representing a delivery type for an order.

The delivery type reference data has the usual code/description, but also an additional boolean property which indicates if further information needs to be entered for the type selected.

So for Emergency deliveries additional data is required. The additional data entry fields would be set visible if Emergency was selected, otherwise hidden

My ViewModel contains <List>ReferenceDeliveryTypes which contains the 3 properties.
I have created a SelectListItems from the ViewModel data

@Html.DropDownListFor(model => model.DeliveryTypeCode, 
    new SelectList(Model.ReferenceDeliveryTypes as System.Collections.IEnumerable, 
        "DeliveryTypeCode", "DeliveryTypeDescription"), new { id = "ddlDeliveryType" })

How can I call a jQuery function on change of the delivery type, pass the selected code and check the Model.ReferenceDeliveryTypes for that code to see if the additional data property is true/false to show/hide the additional fields div?

I have managed to get the jQuery function called to pass the value.

$(function () {

$('#ddlDeliveryType').change(function () {
    var value = $(this).val();
    alert(value);
});

});

  • 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-06-17T10:43:42+00:00Added an answer on June 17, 2026 at 10:43 am

    I don’t know of any way you can do this using a select list but I suggest the following options:

    • Simple but a hack – add a string to the end of DeliveryTypeDescription, for example (emergency delivery) and check for that in your change function
    • Another hack – multiply DeliveryTypeCode by 10 and add 1 on if it’s an emergency delivery (and then use mod 10 in your change function)
    • Use an Ajax lookup function
    • Load a JavaScript lookup table with the codes which require an emergency delivery
    • Use a hidden field in your form which contains a string list of the emergency codes with a suitable separator

    Good luck

    UPDATE
    For the hidden field option if you use something like 123|456|789| and then use indexOf having appended a | to the selected ID.

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

Sidebar

Related Questions

I have this in my code: SelectList(blah, blah, blah, cu.Customer.CustomerID.ToString()) It gives a error
I have the following code in a view: <div class=wrap_select> @Html.DropDownList(dateRange, new SelectList(Model.DateRange, Value,Text),
Hi I have this code in my view.. <%=Html.DropDownList(ProductTemplate,new SelectList(Model.ProductTemplate,Value,Text))%> I know if this
I have the following code- View- <% Html.BeginForm(); %> <div> <%= Html.DropDownList(DropDownSelectList, new SelectList(
I have the following code which works: ViewBag.Resources = New SelectList(db1.Tbl_Resources, Resource_ID, Resource_FirstName) I
I have a DropDownList populated with a SelectList generated from (an anonymous type) that
I have a SelectList: SelectList DropDownListOfCatergories = new SelectList(UnitOfWork.ClassifiedCategories.FindAll().OrderBy(Order()), Category, Category); This works fine
similar example Problem is my selectlist might have data(plus it's format is something like
I have a List of data that I want to bind to a SelectList
i have this code in View @using (Html.BeginForm()) { @: Location @Html.DropDownList(territryID, (SelectList)ViewBag.Territory, choose

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.