This is my edit.jsp code...In my project 'm having search module where i have to search customer by name...I have provided show edit add and delete link for each customer that is searched...Problem 'm facing is on edit action 'm not retrieving radio button value..i have used if else logic..Bt its not working...My edit.jsp code is:-Radio button name is Payment type.
<%@page contentType="text/html"%> <%@page pageEncoding="UTF-8"%> <%@ page import="java.sql.*" %> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Edit Customer details</title> <meta name="keywords" content="" /> <meta name="description" content="" /> <link href="VTdevelopers.css" rel="stylesheet" type="text/css" /> <script language="javascript"> function f2(edit_customer) { var name = document.edit_customer.name.value; var nom1 = document.edit_customer.nominee1.value; var nom2 = document.edit_customer.nominee2.value; var occu = document.edit_customer.occupation.value; var addr = document.edit_customer.address1.value; var city = document.edit_customer.city.value; var state = document.edit_customer.state.value; var pincode = document.edit_customer.pincode.value; var contact = document.edit_customer.contact.value; var email = document.edit_customer.email.value; var gatno = document.edit_customer.gatno.value; var gunno = document.edit_customer.gunthano.value; var cost = document.edit_customer.cost.value; var amount = document.edit_customer.amount.value; var paydt = document.edit_customer.datum1.value; var chqno = document.edit_customer.chqno.value; var bnknm = document.edit_customer.bankname.value; var paytype = document.edit_customer.payment_method.value; var amt = document.edit_customer.amount1.value; var emailPattern = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/; if(name == "") { alert("Name Can't be blank"); return false; } if(nom1 == "") { alert("First Nominee Can't be blank"); return false; } if(nom2 == "") { alert("Second Nominee Can't be blank"); return false; } if(occu == "") { alert("Occupation Can't be blank"); return false; } if(addr == "") { alert("Address Can't be blank"); return false; } if(city == "") { alert("City Can't be blank"); return false; } if(state == "") { alert("State Can't be blank"); return false; } if(pincode == "") { alert("Pincode Can't be blank"); return false; } if(contact == "") { alert("Contact Number Can't be blank"); return false; } if(gatno == "") { alert("Gat Number Can't be blank"); return false; } if(gunno == "") { alert("Quantity of guntha Can't be blank"); return false; } if(cost == "") { alert("Land cost Can't be blank"); return false; } if(amount == "") { alert("Total Amount Can't be blank"); return false; } if(paydt == "") { alert("Payment date Can't be blank"); return false; } if(paytype == "cheque") { if(chqno == "") { alert("Cheque Number Can't be blank"); return false; } if(bnknm == "") { alert("Bank Name Can't be blank"); return false; } } else { return true; } if(amt == "") { alert("Amount Can't be blank"); return false; } if(emailPattern.test(email)) { return true; } else { alert("Invalid Email Address"); return false; } } function toggle(value) { if(value=='show') { document.edit_customer.chqno.style.visibility = 'visible'; document.edit_customer.bankname.style.visibility = 'visible'; document.getElementById("chq").style.visibility = 'visible'; document.getElementById("bnk").style.visibility = 'visible'; } else { document.edit_customer.chqno.style.visibility = 'hidden'; document.edit_customer.bankname.style.visibility = 'hidden'; document.getElementById("chq").style.visibility = 'hidden'; document.getElementById("bnk").style.visibility = 'hidden'; } } function payment_hide() { document.edit_customer.chqno.style.visibility = 'hidden'; document.edit_customer.bankname.style.visibility = 'hidden'; document.getElementById("chq").style.visibility = 'hidden'; document.getElementById("bnk").style.visibility = 'hidden'; } </script> </head> <body class="body" onload="payment_hide();"> <jsp:include page="links.jsp"/> <% String usn = (String)session.getAttribute("username"); int custid=Integer.parseInt(request.getParameter("cust_id")); int gatid=Integer.parseInt(request.getParameter("gat_id")); //out.println("<a href='edit_form_database.jsp?cust_id="+custid+"' > out.println("<form name='edit_customer' method='post' action='edit_form_database.jsp?cust_id="+custid+"&gat_id="+gatid+"'>");%> <% %> <% try { if(usn == null) { response.sendRedirect("login.jsp"); } } catch(Exception e) { out.println(e); } %> <% Connection con=null; try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); con=DriverManager.getConnection("jdbc:odbc:vtdevelopers","",""); } catch(Exception e) { out.println("<h1>server not functioning well </h1>"); } if(con!=null) { try { String s="select * from customer_details where cust_id="+custid+""; Statement statement = con.createStatement(); ResultSet rs = statement.executeQuery(s); String s1="select * from land_details where cust_id="+custid+" and gat_id="+gatid+" "; Statement stm1 = con.createStatement(); ResultSet rs1 = stm1.executeQuery(s1); String s2="select * from payment_details where cust_id="+custid+" and gat_id="+gatid+" "; Statement stm2 = con.createStatement(); ResultSet rs2 = stm2.executeQuery(s2); while(rs.next()) { %> <table align="right"> <tr> <td> <blink>Welcome <%=(String)session.getAttribute("username")%></blink> </td> <td> <a href="logout.jsp">Logout</a> </td> </tr> </table> <h5 class="loginform"><u>CUSTOMER DETAILS FORM</u></h5> <table cellpadding="0" cellspacing="0" align="center" border="5" bordercolor="#003333" align="center" width="70%"> <tr> <td> <b class="label">Title<b> </td> <td> <select name="title"> <option value="Mr.">Mr.</option> <option value="Mrs.">Mrs.</option> <option value="Miss">Miss.</option> </select> </td> <td> <b class="label">Name<b> </td> <td> <input type="text" value="<%=rs.getString(2)%>" name="name"> </td> </tr> <tr> <td> <b class="label">Name of Nominee1<b> </td> <td> <input type="text" value="<%=rs.getString(10)%>" name="nominee1"> </td> <td> <b class="label">Name of Nominee2<b> </td> <td> <input type="text" value="<%=rs.getString(11)%>" name="nominee2"> </td> </tr> <td> <b class="label">Occupation<b> </td> <td> <input type="text" value="<%=rs.getString(9)%>" name="occupation"> </td> <td> <b class="label">Address<b> </td> <td> <input type="text" value="<%=rs.getString(4)%>" name="address1"> </td> <tr> <td> <b class="label">City<b> </td> <td> <input type="text" value="<%=rs.getString(5)%>" name="city"> </td> <td> <b class="label">State<b> </td> <td> <input type="text" value="<%=rs.getString(6)%>" name="state"> </td> </tr> <tr> <td> <b class="label">Pincode<b> </td> <td> <input type="text" value="<%=rs.getString(7)%>" name="pincode"> </td> <td> <b class="label">Contact No.<b> </td> <td> <input type="text" value="<%=rs.getString(3)%>" name="contact"> </td> </tr> <tr> <td> <b class="label">Email-id<b> </td> <td> <input type="text" value="<%=rs.getString(8)%>" name="email"> </td> <% }while(rs1.next()) { %> </tr> </table> <h5 class="loginform"><u>LAND DETAILS</u></h5> <table cellpadding="0" cellspacing="0" align="center" border="5" bordercolor="#003333" align="center" width="70%"> <tr> <td> <b class="label">Gat No.<b> </td> <td> <input type="text" value="<%=rs1.getString(1)%>" name="gatno"> </td> <td> <b class="label">Quantity Of Guntha<b> </td> <td> <input type="text" value="<%=rs1.getString(2)%>" name="gunthano"> </td> </tr> <tr> <td> <b class="label">Land Cost<b> </td> <td> <input type="text" value="<%=rs1.getString(4)%>" name="cost"> </td> <td> <b class="label">Total Amount<b> </td> <td> <input type="text" value="<%=rs1.getString(3)%>" name="amount" > </td> <% }while(rs2.next()) { %> </tr> </table> <h5 class="loginform"><u>PAYMENT DETAILS</u></h5> <table cellpadding="0" cellspacing="0" align="center" border="5" bordercolor="#003333" align="center" width="70%"> <tr> <td width="25%"> <b class="label">Payment Type<b> </td> <td width="40%"> <% if (<%rs2.getString(1).equals("cash")%>) {%> <INPUT TYPE=radio NAME="payment_method" VALUE="cash" CHECKED onclick="toggle('hide');"><b class="label" >By Cash</b></input> <%} else {%> <INPUT TYPE=radio NAME="payment_method" VALUE="cheque" Checked onclick="toggle('show');"><b class="label">By Cheque</b></input> <%}%> </td> <td> <b class="label">Payment Date<b> </td> <td> <jsp:include page="calendar_1.html" /> </td> </tr> <tr rowspan="4"> <td> <b class="label" id="chq">Cheque Number<b> </td> <td> <input type="text" value="<%=rs2.getString(2)%>" name="chqno"> </td> <td> <b class="label" id="bnk">Bank Name<b> </td> <td> <input type="text" value="<%=rs2.getString(3)%>" name="bankname"> </td> </tr> <tr colspan="2"> <td> <b class="label">Amount<b> </td> <td> <input type="text" value="<%=rs2.getString(6)%>" name="amount"> </td> <% } %> </tr> </table> <h5></h5> <table cellpadding="0" cellspacing="0" align="center" border="0" bordercolor="#003333" align="center" width="70%"> <tr> <td align="center"> <% //out.println("<a href='edit_form_database.jsp?cust_id="+custid+"' ><input type="submit" value="update" name="update" /></a>");%> <input type="submit" value="UPDATE" name="cancel" class="button" onclick="return f2(edit_customer)"> <input type="submit" value="CANCEL" name="cancel" class="button" onclick="show.jsp"> </td> </tr> </table> <% } catch(Exception e) { out.println(e); } } %> </body> </html>
please help me asap its urgent..
Ads