I have a jsp page that contain a button when the user click on the button i want to display a text so any idea how to handle the onClick event from JSP
Thank you in advance
I have a jsp page that contain a button when the user click on the button i want to display a text so any idea how to handle the onClick event from JSP
Thank you in advance
You can do this
<div id='myDiv'></div>
<input id='myButton' type='button' value='My Button' />
<script type="text/javascript">
$('#myButton').click(function()
{
$("#myDiv").html("The text that you want to display");
});
</script>
There is no such event system in servlet/JSP
. In fact you may pass key-value pair data along with the servlet request.
sample.jsp
<form method="post" action="servlet_url">
<input type="submit" name="cmd" value="Add"/>
<input type="submit" name="cmd" value="Delete"/>
</form>
and code in doPost
of servlet
String cmd=request.getParameter("cmd");
if(cmd.equals("Add"))
{
//
}
else
if(cmd.equals("Delete"))
{
//
}