get a value when a radio button clicked
Here is my code sir please help me if any changes in the code please give me sir
thanks in advance..
//login.jsp
<%@ page import="com.antares.servlet.EmployeeControllerServlet"
contentType="text/html; charset=ISO-8859-1"%>
<%@ page import="com.antares.DTO.MassMailDetails"%>
<%@ page import="com.antares.*"%>
<%@page import="com.antares.DAO.EmployeeDataBase"%>
<%@page import="java.util.Hashtable"%>
<%
EmployeeDataBase employeeDataBase = new EmployeeDataBase();
MassMailDetails massDetails = null;
Hashtable<Integer, MassMailDetails> hashtable = employeeDataBase
.findAllMassMailDetails();
int intId = 0;
String strStatus = null, strId = null, strSubject = null, strMatter = null, strMatterFile = null;
%>
<script>
function transfer(id){
var f = document.form;
f.method = "POST";
f.action = "../modify.do?id="+id;
//System.out.println("******* id in jsp login Is ******" +id);
f.submit();
}
</script>
<html>
<body bgcolor="blue">
<head>
<title>Mass E-mails</title>
</head>
<marquee bgcolor="violet">
<h2 dir="rtl">** Welcome To **</h2>
</marquee>
<br>
<br>
<h3 align="center">Antares Systems Limited</h3>
<br>
<br>
<table border="2" align="center" cellspacing="3" width="75%">
<tr>
<td>Select</td>
<td>Id</td>
<td>Subject</td>
<td>Matter</td>
<td>MatterFile</td>
<td>Status</td>
</tr>
<%
System.out.println("**** hashtable size is ***" + hashtable.size());
for (int i = 1; i <= hashtable.size(); ++i) {
System.out.println("****value of i is ***" + i);
massDetails = (MassMailDetails) hashtable.get(i);
intId = massDetails.getId();
strSubject = massDetails.getSubject();
strMatter = massDetails.getMatter();
strMatterFile = massDetails.getMatterFile();
strStatus = massDetails.getStatus();
strId = Integer.toString(intId);
%>
<tr>
<td><input type="radio" value="<%=intId%>" name="mId" onclick="transfer"(<%=massDetails.getId()%> )"><input type="hidden" value="<%=intId%>" name="Id" ></td>
<td><%=intId%></td>
<td><%=strSubject%></td>
<td><%=strMatter%></td>
<td><%=strMatterFile%></td>
<td><%=strStatus%></td>
</tr>
<%
}//closing of for loop
%>
</table>
<form action="../newuser.do" method="post">
<center><input type="submit" value=" New "> <input
type="hidden" name="act" value="1"></center>
</form>
<form action="../delete.do" method="post">
<center><input type="submit" value=" To Delete "> <input
type="hidden" name="act" value="2"></center>
</form>
<form action="../modify.do" method="post">
<center><input type="submit" value=" To Modify"> <input
type="hidden" name="act" value="3"></center>
</form>
<form action="../search.do" method="post">
<center><input type="submit" value=" Test Mail"> <input
type="hidden" name="act" value="4"></center>
</form>
<form action="../employee.do" method="post">
<center><input type="submit" value=" Approval And Send To All ">
<input type="hidden" name="act" value="5"></center>
</form>
</body>
</html>
//EmployeeControllerServlet.java(servlet)
package com.antares.servlet;
import java.io.IOException;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.Hashtable;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import com.antares.DAO.EmployeeDataBase;
import com.antares.DTO.MassMailDetails;
@SuppressWarnings("serial")
public class EmployeeControllerServlet extends HttpServlet {
Connection connection = null;
Statement statement = null;
ResultSet resultSet = null, rs = null;
@Override
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
HttpSession session;
session = request.getSession();
response.setContentType("text/html");
String strAct = request.getParameter("act");
System.out.println("*** String Act is" + strAct);
int intAct = Integer.parseInt(strAct);
String strStatus = null;
EmployeeDataBase empDB = new EmployeeDataBase();
String strId;
int intId;
MassMailDetails massMailDetails=null;
String strSubject;
String strMatter;
String strMatterFile;
int intEmpid1;
switch (intAct) {
case 1:// For a New Entry
System.out
.println("Inside case 1 For Inserting a values of new Entry");
response.sendRedirect("./jsp/NewEntry1.jsp?id");
break;
case 2:// To Delete
System.out.println("Inside case 2 To Delete ");
//strId = (String) session.getAttribute("Id");
strId=request.getParameter("id");
System.out.println("****id " + strId);
intId = Integer.parseInt(strId);
EmployeeDataBase empDataBase = new EmployeeDataBase();
massMailDetails = empDataBase.findDetails(intId);
strSubject = massMailDetails.getSubject();
strMatter = massMailDetails.getMatter();
strMatterFile = massMailDetails.getMatterFile();
strStatus = massMailDetails.getStatus();
System.out.println("******* id Is ******" + strId);
System.out.println("*******Subject is " + strSubject);
if (strId != null) {
session.setAttribute("Id", strId);
}
if (strSubject != null) {
session.setAttribute("Subject", strSubject);
}
if (strMatter != null) {
session.setAttribute("Matter", strMatter);
}
if (strMatterFile != null) {
session.setAttribute("MatterFile", strMatterFile);
}
if (strStatus != null) {
session.setAttribute("Status", strStatus);
}
response.sendRedirect("./jsp/delete1.jsp?id");
break;
case 3:
System.out.println("Inside case 16 For Modifying");
strId = request.getParameter("id");
// System.out.println("******* id Is ******" + strId);
//
// if (strId != null) {
// session.setAttribute("EId", strId);
// }
// strId = (String) session.getAttribute("id");
System.out.println("****id " + strId);
intId = Integer.parseInt(strId);
EmployeeDataBase empdataBase1 = new EmployeeDataBase();
massMailDetails = empdataBase1.findDetails(intId);
strSubject = massMailDetails.getSubject();
strMatter = massMailDetails.getMatter();
strMatterFile = massMailDetails.getMatterFile();
strStatus = massMailDetails.getStatus();
System.out.println("******* id Is ******" + strId);
System.out.println("*******Subject is " + strSubject);
if (strId != null) {
session.setAttribute("Id", strId);
}
if (strSubject != null) {
session.setAttribute("Subject", strSubject);
}
if (strMatter != null) {
session.setAttribute("Matter", strMatter);
}
if (strMatterFile != null) {
session.setAttribute("MatterFile", strMatterFile);
}
if (strStatus != null) {
session.setAttribute("Status", strStatus);
}
response.sendRedirect("./jsp/Modify1.jsp");
break;
case 4:// To Test Mail
System.out.println("Inside case 4 To Test Mail");
response.sendRedirect("./jsp/NewEntry.jsp");
break;
case 5:// To Approval And Send To All
System.out.println("Inside case 5 To Approval And Send To All ");
response.sendRedirect("./jsp/NewEntry.jsp");
break;
case 6:// For a New Entry Getting a Values And Inserting a Values
System.out.println("Inside case 6 To Approval And Send To All ");
strId = request.getParameter("id");
strSubject = request.getParameter("subject");
strMatter = request.getParameter("matter");
strMatterFile = request.getParameter("matterfile");
strStatus = request.getParameter("status");
//intId = Integer.parseInt(strId);
EmployeeDataBase employeeDataBase = new EmployeeDataBase();
massMailDetails = employeeDataBase.insertMassMAilDeails(strSubject,
strMatter, strMatterFile, strStatus);
intId=massMailDetails.getId();
session.setAttribute("Id", intId);
session.setAttribute("Subject", strSubject);
session.setAttribute("Matter", strMatter);
session.setAttribute("MatterFile", strMatterFile);
session.setAttribute("Status", strStatus);
response.sendRedirect("./jsp/NewEntryDetails2.jsp");
break;
case 7:// To Modify
System.out.println("Inside case 7 For Modifying");
strId = request.getParameter("id");
System.out.println("******* empid in modify method " + strId);
strSubject = request.getParameter("sub");
strMatter = request.getParameter("mat");
strMatterFile = request.getParameter("matFile");
strStatus = request.getParameter("stat");
System.out.println("****1 Subject is " + strSubject);
System.out.println("*****1 String MatterFile is " + strMatterFile);
if (strId != null) {
session.setAttribute("Id", strId);
}
if (strSubject != null) {
session.setAttribute("Subject", strSubject);
}
if (strMatter != null) {
session.setAttribute("Matter", strMatter);
}
if (strMatterFile != null) {
session.setAttribute("MatterFile", strMatterFile);
}
if (strStatus != null) {
session.setAttribute("Status", strStatus);
}
System.out.println("****2 Subject is " + strSubject);
System.out.println("*****2 String MatterFile is " + strMatterFile);
strId = (String) session.getAttribute("Id");
intEmpid1 = Integer.parseInt(strId);
session.setAttribute("Id", intEmpid1);
empDB = new EmployeeDataBase();
massMailDetails = empDB.modifyMassMailDetails(intEmpid1, strSubject, strMatter,strMatterFile,strStatus);
strId = request.getParameter("id");
System.out.println("******* empid in modify method " + strId);
strSubject = request.getParameter("sub");
strMatter = request.getParameter("mat");
strMatterFile = request.getParameter("matFile");
strStatus = request.getParameter("stat");
System.out.println("*** 1 value of empid in inserting is " + strId);
session.setAttribute("Id", intEmpid1);
session.setAttribute("strSubject", strSubject);
session.setAttribute("strMatter", strMatter);
session.setAttribute("strMatterFile", strMatterFile);
session.setAttribute("strStatus", strStatus);
response.sendRedirect("./jsp/Modify2.jsp");
break;
case 8:// To Delete
System.out.println("Inside case 8 For Delete");
strId = request.getParameter("id");
if (strId != null) {
session.setAttribute("Id", strId);
}
strId = (String) session.getAttribute("Id");
intEmpid1 = Integer.parseInt(strId);
System.out.println("******* empid in modify method " + strId);
EmployeeDataBase employeeDb = new EmployeeDataBase();
employeeDb.deleteRow(intEmpid1);
response.sendRedirect("./jsp/delete2.jsp");
break;
default:
break;
}
}
}
View Answers
Related Tutorials/Questions & Answers:
get a value when a radio button clicked - JSP-Servletget a
value when a
radio button clicked sorry sir my actual probs is that 1st i m callig a jsp in that i m displaying a table where i used a
radio button to access a
value(also used u r code),then in this jsp i m having a forms
Advertisements
to get radio button value - Strutsto
get radio button value hello friend, i have a problem regarding... two major problems:-
1.these
radio button is not going to select also 2.i want to set the "
value" attribute of
radio button
in the above code.
Can u help
Get radio button value after submiting pageGet radio button value after submiting page
Radio buttons are dynamically generated.After selecting
radio button & submitting the page , the
value of the selected
radio button get displayed in that jsp page.
<
get a radio button click value - JSP-Servletget a
radio button click value thanks sir for sending code ,but i have one probs that is i m getting a null
value i m calling getParameter("id... in the input tag name="
radio" eventhough i m getting a null
value please help me
passing value of radio buttonpassing
value of
radio button hi,i have 3 jframe built using the GUi editor in net beans 6.9. i have two
radio button in the first jframe.i have to
get the selected item appear on the 3rd frame after passing through the second
Struts 2 radio button value problemStruts 2
radio button value problem
When I use s:
radio tag in struts 2, I'm not able to
get the selected
value using document.getElementById... gives first
radio option's
value as the
value for any option selected.
Ex
how to get radio value how to
get radio value how to retrive the option
value and insert the next table pls
give example
Drop down and radio button value on edit action i
get the
value from the database for title and
radio button selected...Drop down and
radio button value on edit action HI,
I have... the
value from dropdown and
radio button..
But the problem goes with edit action
check radio button on retrieving the value from database.check
radio button on retrieving the
value from database. HI
i am... database and according to that i want to check the
cash cheque
radio button... information from database the i want to show
cash
radio button checked.How can i do
radio button value on edit actionradio button value on edit action This is my edit.jsp code...In my......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
HTML Get Radio Button
HTML
Get Radio Button
... the user to select any one of
radio
button from the alternative option.
When a submit
button is
clicked by the user, a
new page get.html is open. The
get method
radio buttonradio button On selecting a
radio button, it should open a aspx page
Radio Button in HTML button from a group of
button.
When a user clicks on a
radio button, it becomes... is written by the text next to the
radio button. It is not the
value attribute...;
<form action="">
<input type="
radio" name="
Button"
value="Water">
radio button - Development process
but
when i click on cr
radio button and enter
value in text box.it enter the msg but it again go to sr
radio button
Hi friend,
Plz give full...
radio button hi,
there is 2
radio button and five text box
Struts 2 Radio Button radio buttons and
I am using Struts2 tag.I want first rado
button to be selected by default.But
when i select the second
radio button and hit on search
button i want to retain the selection of that second
radio button on search list
iPhone Radio Button ExampleiPhone
Radio Button Example Can you please suggest me how to create
Radio button in my iPhone application. Actually, in my application i have two... click on that
button it
get selected and by default it should display unselected
Using radio button in struts - Struts , but the
radio button has only just one
value that i can pass.what can i do to solve...Using
radio button in struts Hello to all ,
I have a big problem... options to choose :
Serial number 12345
radio button - selection 1
radio button Radio Button Problem in jsp.Radio Button Problem in jsp. I have a small doubt in my application, my requirement is to
get a "single selectible row", I generated a
radio button...="
radio"
value="<%=rs.getString("op1")%>" name="radio<%=i%>"/><
Query on radio buttonQuery on
radio button I am having a multiple row in jsp page.They are dynamically coming.
For each row there is one
radio button. I want to select one row only,
i.e I want to fetch the
value of row and on submitting the page
Radio button ValidationRadio button Validation Hi..
How to validate
radio button in java?if the
radio button is not selected an error message should be given...
Please...()==false)){
JOptionPane.showMessageDialog(null,"Please select
radio button validation of radio buttonvalidation of
radio button There are 3
radio button as A,B,W. there are another
radio as 1,2,3.if we select W in first
radio button then should select 2nd one(1,2,3).if we select A or B not need select any one from 1,2,3
Dojo Radio ButtonDojo
Radio Button
.... For creating
radio button you need "dijit.form.CheckBox".
The
radio button do some action on press.
Try Online:
Radio
ButtonADS_TO_REPLACE_1
java radio button and exceptionjava
radio button and exception Dear Sir/Madam,
I have problem with my addBagelRadioButton and addCheeseRadioButton. There should be only 1
radio button can be selected, but somehow 2 can be selected the same time. Also, I
dependent radio button of the
Radio Button is to select only one option at a time. So you don't need...dependent
radio button Hi. I have 4
radio buttons say all,chocolate,cookie,icecream. If I select all the other 3 should not able to be selected
radio button - Development processradio button hello,i want to creat two
radio button.out of which only one can be selected.and can show the contain of selected
radio box Hi friend,
Code to solve the problem :
My Page
Radio 11
access into radio buttonaccess into
radio button access the four fields of database called access,access file and stored in
radio button.please help
Radio button in JSP - JSP-ServletRadio button in JSP Hi!
In my page I have two
radio buttons.
If i select first
radio button. one text field has to be displayed....
If i select second
radio button. text field has to be disappeared.
pls.... help me..
Radio button validation using jsp - JSP-ServletRadio button validation using jsp I had one jsp Page and servlet. I did my validations in servlet for my jsp page which contains the
radio... a
value for
radio Buttons) then it will return to same jsp page with the given
How to hide and show some field on a radio button click and cheque number label and textbox to be invisible
when by cash
radio button is clicked.and they should be visible
when by cheque
radio button is
clicked.
I have...How to hide and show some field on a
radio button click This is my