PDA

View Full Version : coding problem


neha
03-02-2009, 04:51 AM
dear sir i m very new to JSP sir i m getting problem in dynamically changing the option of combobox from database(ms acess) .and after that option being selected for that the record from the databse should be deleted.i am taking two combobox in which values of the options are assigned manually if option like asianpaint is selected then another combobox selects only that record from the database where asian paints found and other combobox dynamically takes that value.plz its very urgent thanx in advance.................

<%
Connection conn = null;
Statement statement = null;
ResultSet resultSet = null;
try {
// Loca JDBC driver.

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection("jdbc:odbc:Bill");
Statement stmt1 = con.createStatement();
Statement stmt2 = con.createStatement();
Statement stmt4 = con.createStatement();
Statement stmt3 =con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE );
ResultSet rs1 = stmt1.executeQuery("Select metermake From Mstore");
ResultSet rs2 = stmt2.executeQuery("Select meterserialno From Mstore WHERE Metermake=' "+txt_mm+ "' ");

ResultSet rs3 = stmt3.executeQuery("Select * From Master_table");
%>

<center>
<H1><b><u>METER INSTALLATION</u></b></H1></center>
<TABLE WIDTH="80%" BORDER=1 align="center" CELLPADDING=3 CELLSPACING=3 bgcolor="#FFCC99"><br><br>
<FORM NAME="frmtwo" method="post" action="meterins.jsp" >

<TR>
<TD valign=top align=left width=200 align="left"><b>For BP</b></TD>
<TD valign=top align=left width=250 align="left">
<%
rs3.last();
%>
<input type="text" name="txt_bp" size="30" value= <%=rs3.getString(1)%> ></TD>

</TR>
<TR>
<TD valign=top align=left width=200 align="left"><b>Meter Make</b> </TD>
<TD valign=top align=left width=100 align="left">
<select NAME ="txt_mm" id="menu" STYLE = "Width: 159" onChange="redirect(this.options.selectedIndex)">


<option value="SAMS">Sams</option>
<option value="XYZ">XYZ</option>
<option value="ABC">ABC</option>


</SELECT></TD></TR>

<TR>
<TD valign=top align=left width=200 align="left"><b>Meter serial no</b></Td>
<TD valign=top align=left width=100 align="left">
<select NAME ="txt_msn" STYLE = "Width: 159" >
<%

while(rs2.next())
{



String v2 = rs2.getString(1); %>

<option value=<% out.print(v2);%> ><%out.print(v2); %></option>
<% }%>

</SELECT></TD></TR><%
}catch(Exception e)
{
out.print(e.getMessage());
//JOptionPane.showMessageDialog(null,""+e);
// response.sendRedirect("http://sanjeev:9999/smu/static-pages/errorpage.html");
}%>

</SELECT>

</TD></TR>



<TR>
<TD valign=top align=left width=200 align="left"><b>Date of Insatallation<b></TD>
<TD valign=top align=left width=250 align="left">
<input type="text" name="txt_dc" size="30"></TD>
</TR>






<TR>
<TD valign=top align=left width=200 align="left"><b>Initial meter reading</b></Td>
<TD valign=top align=left width=250 align="left">
<input type="text" name="txt_ic" size=30> *</TD>


</TR>
</TABLE>

<TR>
<BR><BR> <center>
<TD valign=top width=150 align="center">
<input type="submit" value="CREATE" name="submit"></TD></TR>
<TD valign=top width=200 align="center" >
<input type="RESET" value="RESET" name="RESET"></TD></TR>

</center>
</form>
</BODY>
<SCRIPT language = JavaScript>
var d=new Date();

var date1="";
var dd;
var mm;
var yy;

function setDate()
{

dd=d.getDate();
mm=d.getMonth()+1;
yy=d.getYear();

if(dd<10)
dd="0"+dd;

if(mm<10)
mm="0"+mm;

date1=dd+"/"+mm+"/"+yy;
document.frmtwo.txt_dc.value =date1;


}
setDate();
}

abduraooft
03-02-2009, 08:10 AM
Please edit your above post and add ][/COLOR] tags around your code.