Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Radio button check w/ query results 1

Status
Not open for further replies.

lespaul

Programmer
Feb 4, 2002
7,083
US
So I have a list of records returned from a query that fills my ListRows.jsp. There is a link on each record that when the user selects it, EditForm.jsp opens with the detail information for the selected row. One of the fields in the query is CRTFLG (Mandatory Court) with a value of 0 or 1. I have a radio button group (MandCrt) that depending on the value of CRTFLG I would like the appropriate radio button to be selected. How would I do something like that? Here's what I have in EditForm.jsp so far (feel free to check out Thread-1479415 for details on ListRows.jsp and the class that runs the query)
Code:
<html>
<head>
<%@ page
import="java.util.ArrayList"
import="functions.*,java.util.StringTokenizer" 
language="java"
contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"
%>
<title>NM Statute Maintenance</title>
<link href="theme/Master.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="javascripts.js"></script>
</head>
<body onload='javascript:setFocus();'>
<%
		Library l = new Library();
		ArrayList statuteList = l.getStatuteList();
		
		String dataRow = "";
		String strIndex = (String) session.getAttribute("currentRecord");
		int index = Integer.parseInt(strIndex);
		statuteList = JDBCdefs.getStatutes();
		int listSize = JDBCdefs.getListSize();
		String statute = "", abbrev = "", descrip = "", descripL = "", status= "", NCIC= "", effectiveDate= "", courtMand= "", fine= "", bond= "", chargeType= "", DMVCode= "", CrimHist= "", CrimHistTime= "", origin= "", RepositoryStat= "", user= "", ChsCat= "", IntPre= "", LastDateUpdated= "";
		String msgtext = (String) session.getAttribute("message");
		if (!statuteList.isEmpty())
		{
			dataRow = statuteList.get(index).toString();
			StringTokenizer token = new StringTokenizer(dataRow,"%");
			statute = token.nextToken();
			abbrev = token.nextToken();
			descrip = token.nextToken();
			descripL = token.nextToken();
			status = token.nextToken();
			NCIC = token.nextToken();
			effectiveDate = token.nextToken();
			courtMand = token.nextToken();
			fine = token.nextToken();
			bond = token.nextToken();
			chargeType = token.nextToken();
			DMVCode = token.nextToken();
			CrimHist = token.nextToken();
			CrimHistTime = token.nextToken();
			origin = token.nextToken();
			RepositoryStat = token.nextToken();
			user = token.nextToken();
			ChsCat = token.nextToken();
			IntPre = token.nextToken();
			LastDateUpdated = token.nextToken();
			 
		}
%>
		<div id="content">
		<h1 align="center">NM Statute Maintenance Form</h1>
		<h2 align="center">Traffic Charge Type Only, Count <%= listSize %></h2>
		<h2 align="center">Enter Changes to Description per statute:</h2>
		<form name='editstatute' id='editstatute' method='post' action='process.jsp'>
		<table style="text-align: left; width: 100%;" border="1" cellpadding="2" cellspacing="2">

			<tr>
				<td>Statute Id: <input type="text" name="statute" id="statute" size="14" value="<%= statute %>"/> </td> 
				<td> Charge Abbreviation: <input type="text" name="abbrev" id="abbrev" size="10" value="<%= abbrev %>"/> </td> 
				<td>Status:  <input type="text" name="status" id="status" size="10" value="<%= status %>"/> </td>
			</tr>
    		<tr>
      			<td>Short Description: <input type = "text" size="30" id="descrip" name="descrip" value = " <%= descrip %>"/></td>
				<td>Mandatory Court:<input name="MandCrt" value="1" type="radio"> Yes <input name="MandCrt" value="0" type="radio"> No</td>
      			<td>Effective Date: <input type = "text" size="10" id="effectiveDate" name="effectiveDate" value = " <%= effectiveDate %>" /></td>
      			
    		</tr>
			<tr>
			<td colspan = "3">Extended Description: <input type = "text" size="50" id="descripL" name="descripL" value = " <%= descripL %>" /></td>
			</tr>
			
			<tr>
				<td colspan="3">
					<input type="submit" name="submit" value="Save">
					<input type="submit" name="submit" value="Next">
					<input type="submit" name="submit" value="Previous">
					<input type="submit" name="submit" value="List">
					<input type="submit" name="submit" value="Add">
					<input type="submit" name="submit" value="Delete">
					<input type="submit" name="submit" value="Exit">
				</td>
			</tr>
			<tr>
				<td><input type='hidden' name='formtype' id='formtype' value='edit' /></td>
			</tr>
			<tr>
				<td><input type='text' name='message' id='message' size='80' value='<%= msgtext %>' /></td>
			</tr>
		</table>
		</form>
		</div>
</body>
</html>

disclaimer: this website was thrown together by one of our developers as his personal "edit" for these tables...now some users in the org need to be able to do this in more detail and I've been assigned to make the user site. My coworker gave me what he already had done in order to make it easier on me since this is one of my first web projects. If there is a better or easier way to accomplish what I'm trying to do PLEASE tell me...

Thanks!

Leslie

Have you met Hardy Heron?
 
on a related note, i've added the following:
Code:
<tr>
<td> Charge Type:
<select name="ChargeType">
<option></option>
<option value="D">DWI</option>
<option value="V">Domestic Violence</option>
<option value="F">Felony</option>
<option value="M">Misdemeanor</option>
<option value="P">Parking</option>
<option value="T">Traffic</option>
<option value="O">Other</option>
</td>
</tr>

which gives me a drop down list of the different charge types...how do I set the option list from the query for the current charge type?

Thanks!
Leslie


Leslie

Have you met Hardy Heron?
 
Code:
<html>
<head>
</head>
<body>
<%
String choice = request.getParameter("ChargeType");
System.out.println(choice);
%>
<form action="testselect.jsp">
<select name="ChargeType">
<option></option>
<option value="D" <%if (choice!=null && choice.equals("D")) {%>selected
<%}%> >DWI</option>
<option value="V"  <%if (choice!=null && choice.equals("V")) {%>selected
<%}%> >Domestic Violence</option>
<option value="F">Felony</option>
<option value="M">Misdemeanor</option>
<option value="P">Parking</option>
<option value="T">Traffic</option>
<option value="O">Other</option>
</select>
<input type="submit">
</form>
</body>
</html>
 
The name of the web page that I posted is called testselect.jsp
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top