-
onclick event in jsp
<head>
< script language="javascript">
fun()
{
alert("entered");
document.form1.action="test2.jsp";
}
</script>
</head>
<body>
<form name="form1">
<input type="button" name="next" value="next" onclick="fun();">
</form>
</body>
On clicking the button the corresponding javascript code is called (alert"entered" is coming) but next page "test2.jsp" is not opening.
-
This is a javascript problem, not a java problem. You might have better luck posting on a javascript dedicated forum.
-
You haven't called submit() on the form.
You've just changed the action value.
-
thanks for your reply ..
@tolls:-
but that button is not a submit button . its a normal button which on clicking just transfers to next page. so i have called the function fun() in its onclick event.
its not according to the Document Object model.. i.e. document.form_name.action.
the same code runs well in a normal html file but its not working when using in a servlet.
-
Can you show the code used in a normal html file?
Because I doubt it's the same...
That code above is simply settting the action value for a form.
It will not change the page until that is submitted.