Forum Discussion

ScottWilliams's avatar
ScottWilliams
Qrew Member
9 months ago

Coverting old javascript to qb formula

I've got a formula that was created before javascript was banned from outside codepages. I need to convert the code below so that it will run. Any suggestions?

var text style =  "style=\"text-decoration: none; border: 2px solid white; width:140px; padding: 12px 0; background: " & $bgcolor & "; text-align: center; color: " & $txtcolor & "; display: inline-block; font: normal 24px/1 \"Calibri\", sans-serif; text-shadow: none;";

"<div style=\" position:relative; width:960px; padding: 2px 0; height: auto; \">" & 

    "<a " & $style & " href=\"javascript:" & "$.get('" & [Add Blood Collection Kit] &
    "', function(){" & "location.reload();" & "});" & "void(0);\">Blood Collection Kit</a>" &

"</div>"

It's the href that's giving the issue the problem is I don't understand how to recreate this functionality without javascript. I've read the 'Configure URL Fields' document and have been through the QB University but I'm still at a loss. 



------------------------------
Scott
------------------------------

2 Replies

  • Your button is simply making an API call it seems and then reloading the page. The assumption I'm making is that 'Add Blood Collection Kit' is a URL hitting something in QB. If it's hitting an external endpoint or something more complicated you'll need to employ a code page solution.

    If this is a QB API call for Add block collection kit - you can do something like this: 

    var url = [Add Blood Collection Kit] & "&rdr=" & URLEncode(URLRoot() & "db/" & Dbid() & "?a=DoRedirect&z=" & Rurl());

    "<div style=\" position:relative; width:960px; padding: 2px 0; height: auto; \">" & 

        "<a " & $style & " href='" & $url "' & "void(0);\">Blood Collection Kit</a>" &

    "</div>"

    The doredirect is how QB will hit its own API and then simply land you back on the page you came from. 



    ------------------------------
    Chayce Duncan
    ------------------------------
    • ScottWilliams's avatar
      ScottWilliams
      Qrew Member

      Thank you! That works great. 



      ------------------------------
      Scott
      ------------------------------