무소의 뿔처럼

(검사결과입력화면)과정평가형 정보처리산업기사_v1 진단검사 프로그램 본문

과정평가_정산기_기록/진단검사 프로그램

(검사결과입력화면)과정평가형 정보처리산업기사_v1 진단검사 프로그램

값을변경 2022. 2. 11. 11:56

 

HTML

더보기
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>

<jsp:include page = "header.jsp"></jsp:include>

<section>
	<h3>검사결과입력</h3>
	
	<form action="regiAction.jsp" name="regiForm">
	
	<div class="vTableDiv2">
	<table class="vTable">
		<tr>
			<th> 환자번호</th>
			<td> <input name="p_no"> 예)1001</td>
		</tr>
		<tr>
			<th> 검사코드</th>
			<td> <select name="t_code" id="t_code">
					<option selected="selected" value=""> 검사명
					<option value="T001"> [T001]결핵
					<option value="T002"> [T002]장티푸스
					<option value="T003"> [T003]수두
					<option value="T004"> [T004]홍역
					<option value="T005"> [T005]콜레라
				</select>
			</td>
		</tr>
		<tr>
			<th> 검사시작일자</th>
			<td> <input name="t_sdate"> 예)20200101</td>
		</tr>
		<tr>
			<th> 검사상태</th>
			<td> 
				<input type="radio" name="t_status" value="1">검사중
				<input type="radio" name="t_status" value="2">검사완료
			</td>
		</tr>
		<tr>
			<th> 검사완료일자</th>
			<td> <input name="t_ldate"> 예)20200101</td>
		</tr>
		<tr>
			<th> 검사결과</th>
			<td> 
				<input type="radio" name="t_result" value="X"> 미입력
				<input type="radio" name="t_result" value="P"> 양성
				<input type="radio" name="t_result" value="N"> 음성
			</td>
		</tr>
		<tr>
			<td colspan="2" style="text-align: center;">
				<input type="submit" value="검사결과등록" onclick="return check()">
				<input type="reset" value="다시쓰기" onclick="rewrite()">
			</td>
		</tr>
	</table>
	</div>
	
	</form>
	
</section>

<jsp:include page = "footer.jsp"></jsp:include>

 

input / select : option / radio 태그

검사상태 : 검사중 : '1', 검사완료: '2'

검사결과 : 'X' 미입력/ 'P' 양성/ 'N' 음성

 

입력값 없을때 각 항목에 대해서 알림창 띄우기

     : document.폼이름.태그이름.value.length

function check(){
	
	if(document.regiForm.p_no.value.length == 0 ){
		alert("환자번호가 입력되지 않았습니다!");
		return false;
	} 
    return true;
}

 

모든 항목을 입력 한 후 '검사결과등록' 버튼을 누르면 

/DB에 저장 : action페이지로

/알림창 : '검사결과가 정상적으로 등록되었습니다!'

/ 확인 버튼 누르면 메인화면으로 이동 : response.sendRedirect("index.jsp");

 

actionPage.jsp

더보기
<%

String p_no = request.getParameter("p_no");
String t_code = request.getParameter("t_code");
String t_sdate = request.getParameter("t_sdate");
String t_status = request.getParameter("t_status");
String t_ldate = request.getParameter("t_ldate");
String t_result = request.getParameter("t_result");

	Connection con = null;
	PreparedStatement pstmt = null;
	
	try{
	con = dbcon.getConnection();
	String sql = "insert into tbl_result_202004 values(?, ?, ?, ? ,?, ?)";
	pstmt = con.prepareStatement(sql);
	pstmt.setString(1, p_no);
	pstmt.setString(2, t_code);
	pstmt.setString(3, t_sdate);
	pstmt.setString(4, t_status);
	pstmt.setString(5, t_ldate);
	pstmt.setString(6, t_result);
	pstmt.executeQuery();
	
	response.sendRedirect("index.jsp");
		
	if( pstmt != null) pstmt.close();
	if( con != null) con.close();
	
	
	}catch(Exception e){
		e.printStackTrace();
	}
%>

 

javascript.js

더보기
function check(){
	
	if(document.regiForm.p_no.value.length == 0 ){
		alert("환자번호가 입력되지 않았습니다!");
		return false;
	} 

	if(document.regiForm.t_code.value.length == 0 ){
		alert("검사코드가 선택되지 않았습니다!");
		return false;
	} 

	if(document.regiForm.t_sdate.value.length == 0 ){
		alert("검사시작일자가 입력되지 않았습니다!");
		return false;
	} 
	
	if(document.regiForm.t_status.value.length == 0){
		alert("검사상태가 선택되지 않았습니다.");
		return false;
	}
	if(document.regiForm.t_ldate.value.length == 0){
		alert("검사완료일자가 입력되지 않았습니다.");
		return false;
	}
	if(document.regiForm.t_result.value.length == 0){
		alert("검사결과가 선택되지 않았습니다.");
		return false;
	}
	
	alert("검사결과가 정상적으로 등록되었습니다. ")
	return true;
}

 

 

Give focus to a radio button:

document.getElementById("myRadio").focus();

출처:https://www.w3schools.com/jsref/met_radio_focus.asp

Comments