Reputation: 8451
I would like to be able to set values of integers from the UI and have it set to javascript. Basically I'm working with a C3 chart, I'm using the max and min functions. I would like to have a user change those values from the UI and in turn change the value of the javascript. Here is the function that sets the y axis of the chart:
$(function(){
instance.axis.max();
});
You can basically set the value as the parameter of max. This works as I intend it to but how can I make it dynamic from the UI. Right now I have this text field setup that I would like to wire up to change the max value here is the text field
<div class="y-axis">
<input type="number" id="replyNumber" min="0" data-bind="value:replyNumber" />
</div>
Is there a way I can set a data attribute to the html and have it set to the javascript?
Upvotes: 2
Views: 587
Reputation: 1181
Your are using JQuery. So, you can do this as below
$(function(){
var number = $("#replyNumber").attr('min');
//if this is not number then convert it into number.
// number = Number(number);
instance.axis.max(number);
});
Upvotes: 2