0

I'm trying to get input from jQuery daterange picker and storing it in global variables which I can call in test.js. My test.js has a MongoDB aggregate framework that outputs a JSON file with Time, Humidity and Temperature. These values are used to plot a line chart.

    var startValue, endValue;
    $("#from").datepicker(
    {
        onSelect: function()
        {
             startValue = $(this).datepicker('getDate');

        }

    });

$("#to").datepicker(
    {
        onSelect: function()
        {
            endValue = $(this).datepicker('getDate');
        }
    });

index.html

<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/smoothness/jquery-ui.css">
<script src="//code.jquery.com/jquery-1.12.4.js"></script>
<script src="//code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<p>Start Date: <input type="text" id="from"></p>
<p>End Date: <input type="text" id="to"></p>
<input type="submit" value="Get Data">

test.js

{ $match : { datetime : { $gt : startDate, $lt : endDate } } },
  {
   $group: {
    _id:{
    "$add": [
     { "$subtract": [
     { "$subtract": [ "$datetime", new Date(0) ] },
     { "$mod": [
    { "$subtract": ["$datetime" , new Date(0) ] },
    offset]}] },
    new Date(0)
     ]},
            Humidity: {$avg: "$humidity"},
            Temperature: {$avg: "$temperature"}

            },
            },

      { $project : { _id : 1 , Humidity : 1, Temperature: 1 } },
       // { $limit : 10 },
       { $sort :  {"_id":1, "Humidity":1, "Temperature": 1}}

I will like to use a click event to update the variable so I can use it in my test.js

Ekom
  • 599
  • 3
  • 8
  • 24
  • Possible duplicate of [Getting value from JQUERY datepicker](http://stackoverflow.com/questions/8147108/getting-value-from-jquery-datepicker). – diogo Jan 04 '17 at 22:37
  • @dscastro thanks for pointing that out. But it doesn't contain the dropdown event. – Ekom Jan 04 '17 at 22:46
  • please, you need to provide as many details as possible, in order to make it clearer. Please, update your questions with more informations, as well as code, ok? :) – diogo Jan 04 '17 at 22:47
  • @dscastro Just updated my code. – Ekom Jan 04 '17 at 23:10
  • Still not clear, it depends on what your "another JS file" will do with them. Can you post its code too? – diogo Jan 04 '17 at 23:35
  • Please see update. – Ekom Jan 04 '17 at 23:54

0 Answers0