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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T13:27:58+00:00 2026-06-08T13:27:58+00:00

In a form I have a select box with several options, each representing a

  • 0

In a form I have a select box with several options, each representing a report with various variables which influence the rest of the form. Some reports require a start date, others an end date, some require both. I have bound the requirements for each of the reports to the option-elements like this:

<select data-bind="value: ReportId">
    <option value="ID" data-hasStartDate="BOOL" data-hasEndDate="BOOL">Report name</option>
</select>

<input data-bind="visible: hasStartDate" />
<input data-bind="visible: hasEndDate" />

with ID being the id of the report and BOOL being either true or false. I use knockout to data-bind the value of the select-box to the reportId. But I could not figure out how to bind the hasStartDate and hasEndDate-values to a Knockout observable in order to show the appropriate form elements.

Even with custom bindings, I needed a normal jQuery onChange-event in order to apply the values to the Knockout-values hasStartDate and hasEndDate. Is it possible to do it entirely with Knockout itself?

  • 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-08T13:28:00+00:00Added an answer on June 8, 2026 at 1:28 pm

    Have you tried using the options binding for select boxes?

    You also can’t bind knockout using data-whatever="some value". You always use data-bind, like so: data-bind="bindingtype: value".

    Edit:
    That being said… If you want to get the data from a selected option in a <select> element, I would use the following jQuery:

    $("select").on('change', function() {
       var selectedData = $(this).find(":selected").data("stuff");
    });
    

    You can then use selectedData and apply this to a knockout view model.

    Working example in a fiddle: http://jsfiddle.net/RZq6Q/4/

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

Sidebar

Related Questions

i have one form which have some input box and some select box. i
I have... a dynamic populated select box several input boxes a submit button form
I have a html form which have a select list box from which you
I have a select box on a form, which carries an incremental rel attribute.
I have a form which has a select box with name of cities from
I have a popup select box in a form in my jQuery Mobile application.
I have a form in a .html files where input/select box looks like this
I have the following multi-select box in a HTML form, where user can select
I have a vaadin form with huge number of fields in it(textbox, select box
I have a combo box in my form with Member IDs, when I select

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.