Friday, May 17, 2024
 Popular · Latest · Hot · Upcoming
135
rated 0 times [  139] [ 4]  / answers: 1 / hits: 33438  / 11 Years ago, wed, august 21, 2013, 12:00:00

I'm trying to call a function and activate an alert through it in my JSP.

This is what i've done so far:



<html>
<head>
<script type=text/javascript>
<meta http-equiv=Content-Type content=text/html; charset=ISO-8859-1>

function myFunction( test )
{
alert( test );
}
</script>
<title>Success</title>
</head>
<body>
<c:set var=test scope=request value=${requestScope.userDetails }></c:set>
<input type=button id=sample_button onclick=myFunction(${test.userName}) value=test>
</body>
</html>


What is wrong with my code?


More From » html

 Answers
113

In addition to that, You might also need to add a single quote inside the calling function



<input type=button id=sample_button onclick=myFunction('${test.userName}') value=test>


Check for javascript errors & verify the generated HTML in browser


[#76250] Monday, August 19, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
victorr

Total Points: 193
Total Questions: 86
Total Answers: 105

Location: Pitcairn Islands
Member since Thu, Jun 24, 2021
3 Years ago
victorr questions
Fri, Nov 13, 20, 00:00, 4 Years ago
Sat, Jul 25, 20, 00:00, 4 Years ago
Thu, Jun 11, 20, 00:00, 4 Years ago
;