简体   繁体   中英

Passing Jsp variable to javascript as a function parameter

I have the same query as. Pass a JSP variable as parameter to javascript function However, If i use onclick="pagetype('<%=uname%>'); i'm getting illegal start of type error. Please help to fix this.

Yes.. <%@ page contentType= "text/html" pageEncoding="UTF-8" %>

Have you put the end double quote?

onclick="pagetype('<%=uname%>')"

The error is a javascript error ? If it is, Is <%=uname%> visible in the page source?

Have you put something like <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %> at the top of the jsp?

  1. String date1 is inside a loop. You won't be able to get its value outside.
  2. change alert2('<%=date1'); to alert2('<%= date1 %>');

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM