Script :
<script language="JavaScript">
function submitData(teachGeneralId,tName,tDesig) {
alert(teachGeneralId);
teacherName = document.getElementById(tName).value; // must get this way
alert(teacherName);
teacherDesig = document.getElementById(tDesig).value; // must get this way
alert(teacherDesig);
window.location = "recallTeachListPageLoad.do?teachGeneralId="+teachGeneralId+"&teacherName="+teacherName+"&teacherDesig="+teacherDesig;
alert("S2");
}
</script>
jsp page:
<div style="float:left; height:auto; width:800px;">
<table style="width:500px; height:auto;">
<tr>
<td> </td>
<td><input style="height:26px;" class="form-control input-sm" id="" name="" type="text" value="<s:property value='teachGeneralId'/>"/></td>
</tr>
<tr>
<td width="159">Teacher Name :</td>
<td width="329"><input style="height:26px;" class="form-control input-sm" id="tName" name="" type="text" value="<s:property value='teacherName'/>"/></td>
</tr>
<tr>
<td>Designation Id/Name :</td>
<td><input style="height:26px;" class="form-control input-sm" id="tDesig" name="" type="text" value="<s:property value='teacherDesig'/>"/></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td><input id="Input" name="Input" type="button" value="EditORupdate" onClick="submitData('<s:property value='teachGeneralId'/>','tName','tDesig');"/></td>
</tr>
</table>
</div>
java action class:
private String eachTeacherVal;
private String teachGeneralId;
private String teacherName;
private String teacherDesig;
//teachGeneralId //No need 2nd time declare
//teacherName //No need 2nd time declare
//eachTeacherVal //No need 2nd time declare
//Do Edit
public String recallTeachListPage(){
TeacherListSql teacherListSql = new TeacherListSql();
teacherListSql.getUpdateTable(teachGeneralId,teacherName);
teacherList();
return "recallTeachListPage";
}
SQL file:
//Update statement
public void getUpdateTable(String teachGeneralId,String teacherName){
System.out.println("kaniz");
boolean fg = true;
con = dbc.connectDB();
if (con == null) {
fg = false;
}
if (fg) {
try {
st = con.createStatement();
//query = "insert into fn_bank(BANK_ID,BANK_NAME,ENTRY_TIMESTAMP,COMPANY_NO) values ('"+bank_id+"','"+bankName+"',sysdate,'1')";
//queryUpdate = "update tech_general_info set TECH_NAME = '"+teacherName+"',DESIGNATION_NAME = '"+teacherDesig+"' where TECH_GENERAL_INFO_ID='"+teachGeneralId+"'";
queryUpdate = "update tech_general_info set TECH_NAME = '"+teacherName+"' where TECH_GENERAL_INFO_ID='"+teachGeneralId+"'";
System.out.println("QueryUpdate" + queryUpdate);
//st.execute(query);//It is use for insertQuery
st.executeUpdate(queryUpdate);
} catch (SQLException sq) {
sq.printStackTrace();
} finally {
try {
if (rs != null) {
rs.close();
}
con.close();
} catch (SQLException ex) {
ex.printStackTrace();
}
}
}
//return "getBankInfoPageReturn"; //Remember insert query not Return;.Only select query return List.
}
No comments:
Post a Comment