Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Java and JDK > JSP Basics
|
JSP Basics Beginning-level questions on JSP. More advanced coders should post to Pro JSP.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the JSP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 3rd, 2004, 07:36 AM
Authorized User
 
Join Date: Oct 2004
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
Default prob.. in radio button

i have a radio button, i want to do that if i select that radio button then it displays Y in database and shows it, otherwise it shows N.

In my form it doesn't shows Y or N... but it shows hold(which is the value of hold button)..

In my oracle database its data type is CHAR(1)...

this is the radio button:

Hold <input type=radio name="hold" value="hold" >

and my form code is as follow:


<html>
<body>
<table>
<tr>
<td>

<%@ page import="javax.servlet.*" %>
<%@ page import="javax.servlet.http.*" %>
<%@ page language="java" import="java.sql.*" %>

<%
try {

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection conn=DriverManager.getConnection("jdbc:odbc:pf","s cott","ttlscott");
System.out.println("got connection");

%>

<%

String action = request.getParameter("action");
if (action != null && action.equals("save")) {
conn.setAutoCommit(false);

PreparedStatement pstmt = conn.prepareStatement(
("INSERT INTO pay_header VALUES (?)"));

char pay_type;

if (request.getParameter("pay_type") != null) {pay_type = 'Y';} else {pay_post = 'N';}
pstmt.setString(1,request.getParameter("pay_type") );


pstmt.executeUpdate();
conn.commit();
conn.setAutoCommit(true);
}




%>


<%

Statement statement = conn.createStatement();


ResultSet rs = statement.executeQuery
("SELECT * FROM pay_header ");





%>

<table>
<tr>
<tr>
<form action="payment_save1.jsp" method="get">
<input type="hidden" value="save" name="action">
<th><input value="<%= request.getParameter("hold") %>" name="pay_type" size="15"></th>
<th><input type="submit" value="save"></th>
</form>
</tr>

<%

while ( rs.next() ) {

%>



<tr>
<form action="payment_save1.jsp" method="get">
<input type="hidden" value="save" name="action">
<td><input value="<%= rs.getString("pay_type") %>" name="pay_type"></td>
<td><input type="submit" value="save"></td>
</form>
</tr>


<%
}
%>
</table>



<%
// Close the ResultSet
rs.close();

// Close the Statement
statement.close();

// Close the Connection
conn.close();
} catch (SQLException sqle) {
out.println(sqle.getMessage());
} catch (Exception e) {
out.println(e.getMessage());
}
%>
</td>
</tr>
</body>
</html>









Similar Threads
Thread Thread Starter Forum Replies Last Post
Radio button gaurisharya C# 2005 2 March 16th, 2008 06:43 AM
radio-button grstad HTML Code Clinic 3 February 28th, 2006 08:32 AM
Radio Button hoailing22 ASP.NET 1.0 and 1.1 Basics 1 June 2nd, 2005 12:08 AM
Button acts depending on radio button values janise Access 4 March 10th, 2004 12:53 AM
radio button damnnono_86 Access 5 October 28th, 2003 02:17 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.