Alex Kibler
Alex Kibler

Reputation: 4954

Trying to create a messagebox or alert which displays the value of an asp-classic variable

I found this post and tried the first suggestion, and while it will display what I need it to, I suddenly get lots and lots of javascript errors. It's generating about 30 expected end of statement errors. The message box works great though, which is why I'm trying to figure out if there's another solution to pop-up the value of an ASP variable. I'm trying to get it to display inside of an ASP function.

Upvotes: 0

Views: 3053

Answers (2)

James-Jesse Drinkard
James-Jesse Drinkard

Reputation: 15703

I had to work with some legacy code recently and had this same problem. This will work as well if the variable was previously defined:

Response.Write "<script language='JavaScript'>alert('The value is " & variable_name& "');</script>"

Upvotes: 0

Alex Kibler
Alex Kibler

Reputation: 4954

Got it!

I ended up using this:

    %><script language=javascript>
    var temp = '<%=message%>';
    alert(temp);
    </script><%

I don't know why I didn't think to do that before!

Upvotes: 1

Related Questions