Can I pass field data into the javascript of a code page through Formula URL?

  • 0
  • 1
  • Question
  • Updated 4 years ago
  • Answered
"<a class=\"Vibrant Alert\" onclick=\"javascript: var qbRid = \" & [Record ID#] & \";void($.getScript('https://my_domain/db/bj63hyvd?a=dbpage&pagename=script.js'));\">Go!</a>"


I know it is possible to pass the data of [Record ID#] up to javascript in my code page as a variable in like fashion, but this doesnt work. Clicking on the button causes nothing to happen.

"<a class=\"Vibrant Alert\" onclick=\"javascript:void($.getScript('https://my_domain/db/bj63hyvd?a=dbpage&pagename=script.js'));\">Go!</a>"


If I remove my variable of qbRid in like fashion, the button launches the code. So the problem comes when the variable is initiated.


Any insights? The code is useless without the Record ID variable.
Photo of Jacob

Jacob

  • 0 Points

Posted 4 years ago

  • 0
  • 1
Photo of Ⲇanom the ultimate (Dan Diebolt)

Ⲇanom the ultimate (Dan Diebolt), Champion

  • 30,024 Points 20k badge 2x thumb
It is a mistake to put any more JavaScript than necessary into a QuickBase formula. You are only asking for problems if you do otherwise. You should always use an image onload field [-] and place all of your script in the module.js.

Pass [Record ID#] Via Data Attribute
https://haversineconsulting.quickbase.com/db/bj4w34nbr

Pastie Database
https://haversineconsulting.quickbase.com/db/bgcwm2m4g?a=dr&rid=420