Now you don't have that submit button named "action" anymore, so it doesn't 'think' that the action object is being set to "SearchRecords" anymore.
Hi,
I just want to call the submitForm1() function on onchange event of location dropdown and want to submit the form to SearchRecords in the code below:(Please see the bold part in code)
[HTML]<%@ page import="java.util.ArrayList"%>
<%@ page import="javax.servlet.*"%>
<%@ page import="javax.servlet.http.*"%>
<html>
<head>
<title> Form </title>
<script language="javascript" type="text/javascript">
function submitForm1()
{
document.forms[0].action="SearchRecords";
alert("fghfhfhf");
document.forms[0].submit();
}
function submitForm2()
{
document.forms[0].action="Search";
document.forms[0].submit();
}
</script>
<%
ArrayList al=(ArrayList)session.getAttribute("str_");
%>
</head>
<body bgcolor="fuschia">
<center>
<font size=7 color="red"> Please Enter the following information: </font>
<form name="form1" method="POST">
<table cellspacing="2" cellpadding="2" border="0">
<tr>
<td><input type="hidden" name="role" id="role"></td>
</tr>
<tr>
<td align="left"><font size=5>Last Name</font></td>
<td> <input type=text name="sn" value="<%=request.getAttribute("lname") %>"></td>
</tr>
<tr>
<td align="left"><font size=5>FullName</font></td>
<td> <input type=text name="cn" value="<%=request.getAttribute("fname")%>"><td>
</tr>
<tr>
<td align="left"><font size=5>Location</font></td>
<td>
<select name="l" onchange="submitForm1();">
<%if(request.getAttribute("location")!=null)%>
<Option value="<%=request.getAttribute("location")%>><%=re quest.getAttribute("location")%></Option>
<Option value="Chandigarh">Chandigarh</Option>
<Option value="Pune">Pune</Option>
<Option value="Banglore">Banglore</Option>
</select> </td>
</tr>
<tr>
<td align="left"><font size=5>Role</font></td>
<%try{%>
<TD>
<select name="erRoles" id="erRoles">
<option>- - - - - - -</option>
<%for(int i=0;i<al.size();i++){%>
<Option value="<%=al.get(i).toString()%>"><%=al.get(i).toS tring()%></Option>
<%}%>
</select>
</TD>
<%}
catch(Exception e)
{
e.printStackTrace();
}%>
</tr>
<tr>
<td align="right"><input type=submit name=action value="Submit" onclick="submitForm2();"></td>
<td align="left"> < input type=reset name="submitButton" value="Reset"></td>
</tr>
</table>
</form>
</center>
</body>
</html>[/HTML]
But it warks fine in Firefox and not in IE.if I use alert after document.forms[0].action="SearchRecords"; it shows neither alert nor submits the form and if i use alert before document.forms[0].action="SearchRecords"; it shows alert box but don't submit the form.
It also shows a Browser warning on bottom left corner Object doesn't support Line 13(i.e.document.forms[0].action="SearchRecords";)
Thanks