dcsimg
www.webdeveloper.com
Results 1 to 3 of 3

Thread: Dynamic SQL Query

  1. #1
    Join Date
    Mar 2017
    Posts
    3

    Dynamic SQL Query

    This code works fine when I need to embed a query. How do I assign a query to values in a drop down or buttons and load the chart? Maybe if-else condition? Like if I click a button, query 1 loads, for button 2, query2 etc. Thanks for the help. Here's the code:

    I am struggling to get a stacked column / bar with this code. I do get a column chart only with the first value (transitions), and I need either a stacked column or a side-by-side column. Please help. This is the code:

    <script>
    var myDB = new ACCESSdb("Mydesktoppath\\Hcharts.accdb", {showErrors:true});
    $(document).ready(function()
    {
    // $("#run").click(function()
    // {
    var jval = myDB.query($('#query').val(),
    {HCScat : true}); //gets json format data


    $('#container').highcharts({
    chart: {type: 'column', style:{fontFamily: 'Arial'}},
    subtitle:{text: "Sending Location"},
    plotOptions: {series:{dataLabels:{enabled:true}}},
    title: {text: "FTE Transitioned"},
    credits:{enabled:false},
    xAxis:{type:'category'},

    series: [{color:"#409c8a",name:"Transitioned",
    data: JSON.parse(jval)
    }]
    });

    // });//end of click function

    }); //end of ready function
    </script>
    </head>
    <div id="container" style="min-width: 600px; height: 400px; margin: 0 auto"></div>
    <textarea id="query" style="width:0px;height:0px; border-width:0px; border-color:#ffffff">
    Select [Sending Location], Round(Sum([FTE Transitioned]),0) as [Transition], Round(Sum([FTE Reduction]),0) as [Reduction] From tblDatabase Group by [Sending Location]
    </textarea>



    ===============
    Result of the Query:
    [["Australia",9,0],["Bangalore",430,409],["Dublin",136,49],["Limerick",63,34],["London",163,52],["Luxembourg",294,0],["Manila",6,0],["North America",284,76],["Singapore",12,2],["Switzerland",0,0],["Tempe",39,1]]
    ===============

  2. #2
    Join Date
    Mar 2007
    Location
    localhost
    Posts
    4,446
    You have posted a JQuery question in the JavaScript forum, you need the JavaScript Frameworks forum.
    --> JavaScript Frameworks like JQuery, Angular, Node <--
    ... and please remember to wrap code with forum BBCode tags:-

    [CODE]...[/CODE] [HTML]...[/HTML] [PHP]...[/PHP]

    If you can't think outside the box, you will be trapped forever with no escape...

  3. #3
    Join Date
    Mar 2017
    Posts
    3
    Thanks. Will move.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles