how to redirect to struts action from java script?
if condition in the script got success then i need to invoke one action in the config xml, otherwise no action invoking the control needs to stay at same page? please help on this?
Java Script
function displayDate()
{
var x=document.getElementsByName("userName")
if(x = "shan")
{
alert("shankarasd");
document.myForm.action ="/setUpForInsertOrUpdate";
document.myForm.submit();
}
}
HTML
config.xml
/success.jsp
/success1.jsp
/success.jsp
解决方案
try it
window.location='youractionname'
This will redirect your window into your destination
If you want to sent your values to other page, then follow this method
pageEncoding="ISO-8859-1"%>
function displayDate()
{
var x=document.getElementsByName("userName")
if(x =="shan")
{
alert("Redirecting");
return true;
}
else{
alert("Not Redirecting");
return false;
}
}
Insert title hereWhat I modified is, changed the function calling from button to form submit.
And removed the unwanted things from function