Skip to main content
Question

query using a variable in html page

  • September 6, 2017
  • 0 replies
  • 61 views

<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.
This topic has been closed for replies.

  • Registered
  • September 6, 2017
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)
                    })

  • Author
  • Registered
  • September 6, 2017
I have this html page in a dialog box.

  • Registered
  • September 7, 2017
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.