Quick Base Discussions

Expand all | Collapse all

query using a variable in html page

  • 1.  query using a variable in html page

    Top
    Contributor
    Posted 09-06-2017 17:24
    <script>
    var a=1594;
    console.log(a)
    </script>
    <script lang="javascript" src="https://tsemerge.quickbase.com/db/
    DBID?a=API_GenResultsTable&apptoken=APPTOKEN&jht=1&query={'29'.EX.+'a'}AND{'6'.XEX.''}AND{'7'.EX.''}OR{'7'.AF.'today'}&clist=30.20.14.6.7.8&slist=6&options=sortorder-A">


    How would {'29'.EX.+'a'} this statement work? I want a to be kRid eventually.


  • 2.  RE: query using a variable in html page

    Bronze
    Contributor
    Posted 09-06-2017 17:33
    This is how I would do it. note you can wrap URL in a var or just use the DBID if used within the app. 

    var query= "{'29'.EX.'" + kRid + "'}AND{'6'.XEX.''}AND{'7'.EX.''}OR{'7'.AF.'today'}";

     $.get(DBID, {
                            act: "API_GenResultsTable",
                            query:query,
                            clist:"30.20.14.6.7.8",
                            slist: "6",
                            options:"sortorder-A"
                        }, function(xml) {

                            $("#results").html(xml)
                        })


  • 3.  RE: query using a variable in html page

    Top
    Contributor
    Posted 09-06-2017 17:47
    I have this html page in a dialog box.


  • 4.  RE: query using a variable in html page

    Bronze
    Contributor
    Posted 09-06-2017 18:02
    That should be fine. Just use the script tags like you did if you need to. Just change the #results to whatever element you want the report to display.


  • 5.  RE: query using a variable in html page

    Top
    Contributor
    Posted 09-06-2017 18:10
    That is not really working for me, there is no way to include a here {'29'.EX.+'a'}?


  • 6.  RE: query using a variable in html page

    Bronze
    Contributor
    Posted 09-06-2017 18:16
    Feel free to reach out if you want to go through a demo of one my HTML pages. Which is loaded on dashboards but could be loaded anywhere. But you would need to get your values for your variables then change the source. I don't think you can enter a variable in the source URL. 

    chuck@chuck.support


  • 7.  RE: query using a variable in html page

    Bronze
    Contributor
    Posted 09-06-2017 18:17
    also the above probably won't work because I didn't include the apptoken


  • 8.  RE: query using a variable in html page

    Top
    Contributor
    Posted 09-07-2017 14:12
    You are not going to be able to dynamically set the src of a script tag that references ?act=API_GenResultsTable&jht=1. This is because that script file references document.write() and that method operates differently between when it is called on initial page load and when it is called later.

    Moreover, nobody uses  document.write() anymore. It is archaic construct left over from the early days of the web and is only used for some obscure edge cases related to having a backup for a missing CDN file. If you are writing your own code page and want to use ?act=API_GenResultsTable call it with &jsa=1 instead and generate your report using a template such as Mustache. Search for API_GenResultsTable and Mustache for historic examples and I think you will find material you can adopt.