if i want two submit buttons ok1 and ok2 if the user click ok1 control goes with 1.jsp or
click ok2 control goes with 2.jsp but ok2 is not working.

is there any mistake two submit buttons then what are methods to resolve


my code is here

<html> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 
<title>JSP Page</title> 
</head> 
<body> 
<form action="1.jsp" method="post"> 
<table> 
<tr> 
<td> 
<input type="text" name="textbox"> 
</td> 
</tr> 
<tr> 
<form action="2.jsp" method="post"> 
<table> 
<tr> 
<td> 
<input type="text" name="textbox2"> 
</td> 
</tr> 
<tr> 
<td> 
<input type="submit" value="ok2"> 
</td> 
</tr> 
</table> 
</form> 
</tr> 
<tr> 
<td> 
<input type="submit" value="ok1"> 
</td> 
</tr> 
</table> 
</form> 

</body> 
</html>

A submit button will forward to the page listed in the form tag, of course. What you need is some java script to add on a query parameter to that url and a "central" site that forwards the request to the proper page based on that parameter.

Member Avatar for rakhi4110

Hi Sasi,

You need to use javascript to dynamically change the action of your form.
And i also noticed that you are trying to use one form within another form.
And i am not sure whether it will work.
Here i'm posting an example of how to dynamically change your action.
See whether it is helpful or not.

<html>
<head>
<script type="text/javascript">
function onsubmitform()
{
 if(document.pressed == 'insert')
  {
   document.f1.action ="check.jsp";
  }
  else
  if(document.pressed == 'update')
  {
    document.f1.action ="check2.jsp";
  }
  return true;
}
</script>
</head>
<body>
<form name="f1" onsubmit="return onsubmitform();">
<select name="tool" id="tool">
    <option value=kim>KIM</option>
    <option value=ontomat>Ontomat Annotizer</option>
    <option value=gate>GATE</option>
</select>
<input type="submit" name="s1" onclick="document.pressed=this.value" value="insert" />
 
<input type="submit" name="s2" onclick="document.pressed=this.value" value="update" />
</form>
</body>
</html>

The check.jsp and the check2.jsp can contain the code which you want to execute upon clicking that button. It is not necessary to be jsp page, it can also be an html page.
Try using this for your problem and let me know if it is solved. Else try to explain your problem more clearly.

Regards,
Rakhi

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.