Search code examples
javascriptjspalertscriptlet

Passing string variable in alert box


I have below script where im passing scriptlet variable to javascript function. But there is no alert box displaying.. Please let me what im missing here..

<script language="JavaScript">
window.onload = function(){
    <%
      String res = request.getParameter("Message");
    %>
    var Value = "<%=res%>";
    alert(Value);
    document.Form.submit();
};
</script>

Thanks in advance


Solution

  • try this....

    <script type="text/javascript">
    window.onload = function(){
    <%
      String res = request.getParameter("Message");
    %>
    var Value = <%=res%>;
    windows.alert(Value);
    document.Form.submit();
    };
    </script>