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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T19:22:09+00:00 2026-06-06T19:22:09+00:00

Fiddle: http://jsfiddle.net/amitava82/dawkn/6/ The input elements will be generated dynamically based on json data received

  • 0

Fiddle: http://jsfiddle.net/amitava82/dawkn/6/

The input elements will be generated dynamically based on json data received from server. Here I’m using text fields but it could be select, radio etc and n number of them. Now, I’m confused how do I get values from these input elements and also associate them with respective models item so that I can send them to server. Appreciate any help. Thanks!

  • 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-06T19:22:10+00:00Added an answer on June 6, 2026 at 7:22 pm

    You need to define custom model for each data. For example:

    function DataModel(opts) {
        var self = this;
        self.Id = ko.observable();
        self.DisplayName = ko.observable();
        self.ValueDisplayType = ko.observable();
        self.Value = ko.observable();
        for (var i in opts)
            try{ self[i](opts[i]); } catch(e) {}
    }
    

    I’ve added the for so you can do this:

    new DataModel({
        "Id": 12,
        "DisplayName": "Rad Accept Time Out",
        "ValueDisplayType": 0
    });
    

    Now when you create the viewModel you can do this:

    var l = data1.length, parsed_data = [];
    for (var i = 0; i < l; i++)
        parsed_data.push( new DataModel(data1[i]) );
    self.models = ko.observableArray(parsed_data);
    

    In your template you can use this:

    <script id="displayTmpl" type="text/html">
        <input type="text" data-bind="value: $data.Value" />
    </script>
    

    and finally in save method:

    self.save = function(){
        var newValues = ko.toJS(self.models);
        console.log(newValue);
    }
    

    function ko.toJS transforms ko.observables to its values. When you have newValues then you can stringify them with JSON for example and send them to the server.

    That’s more or less how I would do that. Feel free to ask additional questions in comments below.

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

Sidebar

Related Questions

Fiddle: http://jsfiddle.net/MhWm5/16/ I have some dynamically generated table rows/values with dynamic IDs <td class=control-group>
In this fiddle http://jsfiddle.net/SySRb/40/ , I created an array with two elements, #f-ONE and
I have this fiddle: http://jsfiddle.net/yub2B/4/ HTML: <input type=text /> <input type=text /> <input type=text
I have this fiddle: http://jsfiddle.net/gY2JV/63/ How come the data is not showing?
Given this little fiddle: http://jsfiddle.net/5Sw3h/8/ I have a navigation panel to the left, a
Here is my fiddle: http://jsfiddle.net/jamesbrighton/wxWgG/4/ HTML: <div> <p class=click>Click 1</p> <p>This should be ignored</p>
Please look at this fiddle: http://jsfiddle.net/dyv88/16/ On IE7, if I put width: 100% on
Here is a sample fiddle: http://jsfiddle.net/K2zyU/4/ The problem I am experiencing is that the
See the fiddle: http://jsfiddle.net/stefek99/9m5NZ/1/ Get the source: http://pastie.org/3654715 Chrome 17 : just works. IE
here is the working fiddle: http://jsfiddle.net/2bNsC/67/ I need to place the 3 items (text

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.