Skip to main content
Question

Use a Variable in a javascript Alert box

  • September 2, 2020
  • 0 replies
  • 205 views

I am trying to create an alert box that returns the value of a variable.  I tried using this:

var text Danger = "<a style=\" text-decoration: none; background: #FF0000; border-radius: 5px; color: #fff; display: inline-block; width: 220px; text-align: center; padding: 8px 20px; font: normal 700 14px/1 \"Calibri\", sans-serif; text-shadow: none; \" href=\"javascript:alert(" & $message & ")\">MS Readiness</a>";

Rather than getting a button that will trigger an alert box I an getting a button that does nothing and the button text is the value of the variable plus ")\>MS Readiness.  

I'm guessing this is a simple syntax error, but I'm not seeing the error.


------------------------------
Paul Peterson
------------------------------
This topic has been closed for replies.

Forum|alt.badge.img+17
  • Community Moderator
  • September 2, 2020
Hi Paul,

I just wanted to give you a heads up that javascript within your forms and buttons directly is something that we don't support and that as we continue to develop QB over time there is always the chance that javascript will break or the responses you get will potentially be inaccurate as we develop. I'm curious what this alert box that returns the valuable of a variable is doing for your work flow? Is it supposed to be altering your end user about a value on the record when they are putting in data or when opening records? Depending on what you are trying to achieve we might have some alternatives that use supported methods we can suggest. Thank you for your time today.

------------------------------
Evan Martinez
Community Marketing Manager
Quick Base
------------------------------

EverettPatterso
Forum|alt.badge.img+10
Close, but string literal was missing the single quotes to enclose the text variable 



var text message = "My Test Message"; var text Danger = "<a style=\" text-decoration: none; background: #FF0000; border-radius: 5px; color: #fff; display: inline-block; width: 220px; text-align: center; padding: 8px 20px; font: normal 700 14px/1 \"Calibri\", sans-serif; text-shadow: none; \" href=\"javascript:alert('" & $message & "')\">MS Readiness</a>"; $dangerโ€‹

------------------------------
Everett Patterson
------------------------------