Tutorial hyperlink and javascript in label - nopri/sqliteboy GitHub Wiki

Tutorial: Hyperlink and Javascript in label

In this tutorial, we will use hyperlink and javascript in label (form/report) to run form/report.

Please note that web browser with javascript support is needed to follow this tutorial. Also, SQLiteBoy extended features must be enabled to use form/report.

For example, in form1, we have one column named a in table1. Current label is: column a.

{
  "table"     : "table1",
  "column"    : "a",
  "label"     : "column a",
  "required"  : 1,
  "reference" : [ ["0", "NO"], ["1", "YES"] ],
  "default"   : "1"
}

Lets assume that we want to use hyperlink as column label. And, when that hyperlink is clicked, report1 will be run, and value of column a will be passed to report1 (to input_a_a key).

We can modify the label:

{
  "table"     : "table1",
  "column"    : "a",
  "label"     : "<a href='#' onclick=\"window.location.href='/report/run/report1?input_a_a='+document.getElementsByName('a')[0].value\">column a</a>",
  "required"  : 1,
  "reference" : [ ["0", "NO"], ["1", "YES"] ],
  "default"   : "1"
}

Note:

  • URI to run report: /report/run/<report_name>
  • URI to run form : /form/run/<form_name>

- input_a_a is defined in report1:

{
  "key"       : "input_a_a",
  "label"     : "column a equals",
  "reference" : [ ["0", "NO"], ["1", "YES"] ],
  "default"   : "1"
}
⚠️ **GitHub.com Fallback** ⚠️