views:

31

answers:

1

Hi,

I'm using the JQuery DatePicker for exchange rate dashboard.How can i retrieve data on clicking specific date.The datepicker should fetch data from database and should display on text fied. The dates should be mark and clickable, and it should navigate to the particular Day Exchange rate Detail when the user clicks on one of the dates.........


screenshot

i'm using Asp.net mvc to implement my exchange rate dashboard. here is exchange rate controller code(http.post)

if (tUsvc.ValidateExchangeRate(fc["Duedate"], fc["BuyingRate"])) //validate and add/update new exchange rate for today
        {
            ExchangeRate rate = new ExchangeRate();
            rate.CurrentDate = Convert.ToDateTime(fc["Duedate"]);
            rate.DollarRate = Convert.ToInt32(fc["Dollar"]);
            rate.BuyingRate = Convert.ToDecimal(fc["BuyingRate"]);
            rate.SellingRate = Convert.ToDecimal(fc["SellingRate"]);
            Ers.Add(rate);
        }
        else           // if not validate display previously updated today's exchange rate
        {
            ViewData["ExchangeRate"] = Ers.GetAll().Last();
            return View("ExchangeRates");
        }
        ExchangeRate erate  =  Ers.GetAll().Last();  //redirect url to display exchange rate after update/add
        ViewData["ExchangeRate"] = Ers.GetSingleExchangeRate(erate.Id);
        return View();
+1  A: 

The short question is "NO". jQuery is a client-side library based on Javascript, which can't directly manage anything on a server. The longer answer would be "You Can" but:- you need to make use of AJAX, ie, perform HTTP requests. You also need server-side scripting support, such as PHP (unless you're using node.js?)

Then simply proceed with the following code:

$('#update-btn').click(function(){
  $.getJSON('get-data.php',{"date":$('#date-picker').val()},function(obj){
    $('#dollar-field').val(obj.dollar);
  });
});

Since you gave me 0 indications on what your code looks like, I proceeded on using fictitious field IDs.

The contents of "get-data.php" would look like:

// set default date
$date='INSERT-DEFAULT-DATE-HERE';
// get date parameter if it was set
if(isset($_REQUEST['date'])$date=$_REQUEST['date'];
// build sql query
$sql='SELECT * FROM table_name WHERE `date`="'.mysql_real_escape_string($date).'"';
// run sql query
$res=mysql_query($sql);
// get the first row
$obj=mysql_fetch_assoc($res);
// write encoded object
echo json_encode($obj):

If you didn't understand my code, just ask and I'll explain it.

Christian Sciberras
I think he is asking for retrieve data on clicking specific date.Rather code is working on clicking update button.
Amit
Amit, he's not clear about it. I'm not sure whether his problem is server-side scripting OR using ajax OR simply how to get the selected date. I tried tackling them together.
Christian Sciberras
my question is how to retrieve data on clicking this plugin UI (i.e. clicking day on UI) and it should display on textbox field.All the data are stored in db.
Mik-Mark
Mik, great, see how not listing your full requirements wastes people's time. If I knew you used Asp.net, I wouldn't have bothered with a reply, since I don't use ASP.The above advice (my answer) is all that I can offer at this point.
Christian Sciberras
i think here the problem in not about asp.net.it's all about jquery.I need a jquery help to make UI clickable and perform certain action on url for fetching data.I'll handle .net code side.
Mik-Mark
Well, see my first script? It's everything you need to do what you want.
Christian Sciberras