Current File : //home/obabain/ms_obaba_in/editmenu.jsp
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
    <%@ include file="Connection.jsp" %>
    <%
    String id=request.getParameter("Id");
    Statement sdet=con.createStatement();
    ResultSet rd=sdet.executeQuery("SELECT * FROM ip_menu_creation where id="+id+"");
    while(rd.next())
    {
    %>
    <%!int id;%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body onload="loadselect(<%=rd.getString("menu_parent_id")%>,<%=rd.getString("status")%>)">
<form method="post">
<%@include file="master.jsp" %>
<div class="content">
<div class="row">
<div class="col-md-9">
<table class="table" style="width:50%;background-color:white;">
<tr>
<td>
Menu Name</td>
<td>
<input type="text" name="mname" class="form-control" value="<%=rd.getString("menu_name") %>">
</td>
</tr>
<tr>
<td>
Menu Parent</td>
<td>
<select name="mparent" class="form-control" id="ddlparent">
<option value="0">--Select--</option>
<%

Statement stmt=con.createStatement();
ResultSet r=stmt.executeQuery("select * from ip_menu_creation where menu_parent_id=0 ");
while(r.next())
{
%>

<option value="<%=r.getString("id") %>"><%=r.getString("menu_name") %></option>
<%} %>
</select>
</td>
</tr>
<tr>
<td>
Status</td>
<td>
<select name="status" class="form-control"  id="ddlstatus"><option value="0">Active</option>
<option value="1">Inactive</option>

</select>
</td>
</tr>
<tr>
<td>
Redirection</td>
<td>
<input type="text" name="redirect" class="form-control" value="<%=rd.getString("redirection_page") %>">
</td>
</tr>
<tr>
<td>
Sort Order</td>
<td>
<input type="text" name="sorder" class="form-control" value="<%=rd.getString("sortorder") %>">
</td>
</tr>
<tr>
<td>
<input type="submit" name="save" class="btn btn-success">
</td>
</tr>

</table>
<%} %>
</div>

<%
try{
String name=request.getParameter("mname");
String parent=request.getParameter("mparent");
String status=request.getParameter("status");
String redir=request.getParameter("redirect");
String order=request.getParameter("sorder");

if(name.length()!=0 || name!=null)
{
	Statement stm=con.createStatement();
int i=stm.executeUpdate("update ip_menu_creation set menu_name='"+name+"',menu_parent_id="+parent+",redirection_page='"+redir+"',status="+status+",sortorder="+order+",createdby=1 where id="+id+"");
response.sendRedirect("MenuCreation.jsp");
}
}
catch(Exception el){}

%> 
</div>
</div>

</form>
<script>
function loadselect(ddl,ddls)
{
	
	document.getElementById("ddlparent").value=ddl;
	document.getElementById("ddlstatus").value=ddls;
	}
</script>
</body>
</html>