I developed in Java EE and I want to take a javascript variable (which I obtained from another jsp page mother) I want to use it in a query sql server in the same page pop1.jsp, here is my code:
<html>
<head>
<script type="text/javascript">
var valeur= opener.document.getElementById("formulaireFournisseur").idfour.value;
function affectation(){
var valeur;
valeur= opener.document.getElementById("formulaireFournisseur").idfour.value;
document.write(valeur);
document.getElementById("form").champ.value=opener.document.getElementById("formulaireFournisseur").idfour.value;
}
</script>
</head>
<body>
<sql:query var="result" dataSource="Achat">
Select * FROM dbo.Fournisseur WHERE nom LIKE ?
</sql:query>
<sql:param> '%$valeur%' </sql:param>
<table border="1">
<!-- column headers -->
<tr>
<c:forEach var="columnName" items="${result.columnNames}">
<th><c:out value="${columnName}"/></th>
</c:forEach>
</tr>
<!-- column data -->
<c:forEach var="row" items="${result.rowsByIndex}">
<tr id="${result.rowsByIndex}" ondblclick="SelectLigne(this);window.close() ">
<c:forEach var="column" items="${row}">
<td><c:out value="${column}"/></td>
</c:forEach>
</tr>
</c:forEach>
</table>
</body>
</html>
I want to recover $ value in the code of the SQL query and execute my sql mequete correctly. please help me
Your solution will not work. It tries to work in the opposite order. Also, as sql and javascript are executed on different machines (server and client) you will have to rewrite this.
You probably need to construct a form with the valeur value to submit to the server.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.