Divya Sharma Divya Sharma - 1 year ago 102
jQuery Question

how to call variable or property inside an object in javascript or jquery

I am getting the dates(start and the end dates) dynamically from the servers in json format, so i need to implement in my bootstrap date picker, but its not working here is the code
note: for now i am just implementing my using the variables names

// var start = obj1.start;
// var end = obj1.end;
var start = 01/02/1906;
var end = 01/02/1998;

autoclose: true,
startDate: 'start',
endDate: 'end',

Answer Source

The quotes ' or even " around variables will make them only to strings, not a variable reverence. Just remove them the quotes.

But on the other hand, you have to add the quotes on your variable declaration, because these are strings.

// add quotes here
var start = '01/02/1906';
var end = '01/02/1998';

    autoclose: true,

    // and remove the quotes here
    startDate: start,
    endDate: end,
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download