How to change the value by the option name of an HTML select tag?

0

I hope and they are well, what happens is that I am consuming some services and the content of that value is painted as it comes from the database, as you well know that it is already productive and I do not have permission to do what the BD, an ejm is: change "DF" to "Mexico City" (The latter that is only painted in the JSP view) so that I understand this is the code:

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<link rel="stylesheet" href="mbbn_mult_web_pub/css/afiNom/style.css">
<link rel="stylesheet" href="mbbn_mult_web_pub/css/afiNom/datosRegistrados.css">
<link rel="shortcut icon" href="/favicon.ico">
<link rel="apple-touch-icon" href="/apple-touch-icon.png">
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
<meta name="description" content="">
<meta name="author" content="XMY2147">
</head>
<body>
	<div id="titulo1" align="left">Llena los siguientes campos:</div>
	<div>
		<nav>
		<h3 align="center">Los datos que quedarán registrados son:</h3>
		<div class="content">

			<form:form commandName="persona">
				<input type="hidden" name="_flowExecutionKey"
					value="${flowExecutionKey}" />
				<div id="contenedor">
					<div id="contenidos">
						<div id="columna1">
							<label>Nombre:</label>
						</div>
						<div id="columna2">
							<!-- <label>Diana Baez Dorantes</label> -->
							<label>${persona.name} ${persona.motherLastName} ${persona.lastName}</label>
						</div>
					</div>
					<div id="contenidos">
						<div id="columna1">
							<label>Fecha de nacimiento:</label>
						</div>
						<div id="columna2">
							<!-- <label>11-03-1980</label> -->
							<label>${persona.birthDate}</label>
						</div>
					</div>
					<div id="contenidos">
						<div id="columna1">
							<label>Lugar de nacimiento:</label>
						</div>
						<div id="columna2">
							<!-- <label>Ciudad de México</label> -->
							<label>${persona.birthPlace}</label>
						</div>
					</div>
					<div id="contenidos">
						<div id="columna1">
							<label>G&eacute;nero:</label>
						</div>
						<div id="columna2">
							<!-- <label>Femenino</label> -->
							<label>${persona.sex}</label>
						</div>
					</div>
					<div id="contenidos">
						<div id="columna1">
							<label>CURP:</label>
						</div>
						<div id="columna2">
							<!-- <label>BADD110313HCMLNS09</label> -->
							<label>${persona.curp}</label>
						</div>
					</div>
					<div id="contenidos">
						<div id="columna1">
							<label>Correo electr&oacute;nico:</label>
						</div>
						<div id="columna2">
							<!-- <label>[email protected] </label> -->
							<label>${persona.email}</label>
						</div>
					</div>
					<div id="contenidos">
						<div id="columna1">
							<label>Teléfono celular:</label>
						</div>
						<div id="columna2">
							<!-- <label>5525608650</label> -->
							<label>${persona.telefonoCelular}</label>
						</div>
					</div>
					<div id="contenidos">
						<div id="columna1">
							<label>Fecha de operación:</label>
						</div>
						<div id="columna2">
							<label>27-02-2017</label>
						</div>
					</div>
					<div id="contenidos">
						<div id="columna1">
							<label>Hora de operación:</label>
						</div>
						<div id="columna2">
							<label>14:00:02</label>
						</div>
					</div>
					<div id="candadoStyle"></div>
				</div>
				<div class="content1">
					<div id="envioCodigo">
						<div id="men_otp_1">
							<p align="center">
								Te hemos enviado un c&oacute;digo a tu celular. Tienes 5 minutos
								para ingresarlo. Al momento de introducir el c&oacute;digo,
								est&aacute;s aceptando que <strong>Bancomer</strong> te haga
								llegar notificaciones al celular que acabas de proporcionar.
							</p>
						</div>

						<div id="txtCodSeguridad" align="center">
							<table>
								<tr>
									<td align="right">Ingresa código de seguridad:</td>
									<td width="330px"><input type="text" id="inputCodSeg"></td>
								</tr>
							</table>
							<div class="lblReciCod">
								<a>No recibí codigo de seguridad</a>
								<!-- <label class="lblReciCod">No recibí codigo de seguridad</label> -->
							</div>
						</div>
					</div>
					<br>
				</div>
				<div class="submit">
					<input class="styleBotonCancel send" type="submit"
						name="_eventId_cancel" value="Cancelar"> <input
						class="styleBotonConfirm send" type="submit" name="_eventId_fin"
						value="Confirmar">
				</div>
			</form:form>
		</div>
		</nav>
	</div>
</body>
</html>

Practically what it requires is to change these values, that is, to be painted in the JSP. I hope and you can provide me with an example so that you can guide me, in advance I send you a cordial greeting

Note: if any other information is required, I will gladly place it.

    
asked by JUAN JOSE BUSTAMANTE SOLIS 04.10.2017 в 16:48
source

1 answer

0

Use Javascript. All modern browsers support Javascript, it's a MUST HAVE.

<script> /*código Javascript*/ </script>

It is essential that you have the value you want to write. For this you will need to obtain it from the database, through the service you consume, of course.

Remember this: JAVA runs on the SERVER. JAVASCRIPT runs in the BROWSER.

The HTML page is compiled and regenerated on the Server and the Java code generates HTML code. This is where you get your object and you must access it through Javascript (this will be done in the browser):

${objeto.atributo}

You'll have to do one:

var option = document.getElementById("idOption");
var name = option.getAttribute("name");
option.setAttribute("value", name);

Make sure you use good coding to show the values and it should be enough.

    
answered by 05.10.2017 в 01:09