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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T13:59:53+00:00 2026-06-11T13:59:53+00:00

I am fairly new to Knockout JS. I am trying to do a simple

  • 0

I am fairly new to Knockout JS. I am trying to do a simple task, if the drop down menu changes show a helper text depending on the value selected in the drop down list.

My example is located on jsFiddle: http://jsfiddle.net/dnfCb/10/

Note: I am not sure if linking to jsFiddle is allowed, if not I will paste the code here. It seems the ko.computed event only fires on load. Can’t seem to get it to fire when the criteria changes.

Thank you for your time.

  • 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-11T13:59:54+00:00Added an answer on June 11, 2026 at 1:59 pm

    You need to bind your <select> value to an actual observable property to see changes.

    <-- ------------------------ here....................... -->
    <select name="search_option" data-bind="value: criteria">
        <option value="O">Order Search</option>
        <option value="P">PO Number Search</option>
    </select>
    

    and

    var orderSearchViewModel = {
       criteria: ko.observable("O")   // give a default value
    };
    
    orderSearchViewModel.helperText = ko.computed(function() {
        if (this.criteria() == "P") {
            return "Searching by PO Number";
        }else {
            return "Searching by Order Number";
        }
    }, orderSearchViewModel);
    
    ko.applyBindings(orderSearchViewModel);​
    

    Note that criteria is a function that needs to executed in order to get the underlying value, so

    if (this.criteria == "P")
    

    would not work.

    http://jsfiddle.net/dnfCb/11/


    BTW, I think the the self-contained view model set-up is a little nicer:

    function OrderSearchViewModel() {
      var self = this;
    
      this.criteria = ko.observable("O");
      this.helperText = ko.computed(function() {
        if ( self.criteria() == "P" ) {
          return "Searching by PO Number";
        } else {
          return "Searching by Order Number";
        }
      });
    }
    
    ko.applyBindings( new OrderSearchViewModel() );​
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Fairly new to Objective C and trying to work within Storyboards given it's the
I fairly new to JQuery and perhaps trying to achieve something that might be
Fairly new to MVC3 and I am doing a simple project for testing purposes.
im fairly new to android development, but i'm having some trouble trying to make
Still fairly new to android. I am trying to learn how to create a
Fairly new to jQuery, trying to use Autocomplete. Went to http://jqueryui.com/download to build my
I'm fairly new to NHibernate and I'm trying to modify a criteria that currently
I am fairly new to Knockout and I am looking for way to format
Being fairly new to objective-c and developing for ios I'm trying to figure out
I'm fairly new to ASP.NET and trying to learn how things are done. I

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.