I have a problem with a filling I do with JavaScript when it comes to the functionality of a form in which I manage the database, it has the buttons to insert, delete, modify and display. When I want to delete or modify I use a function that selects the data from the database and fills them in its respective textbox.
My problem is that at the time that a string type data has a space, I do not directly fill any textbox.
This is my filling method.
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
<script>
function llenar(codigo,nombre,precio,pro)
{
document.getElementById("idd").value=codigo;
document.getElementById("nombree").value=nombre;
document.getElementById("precioo").value=precio;
document.getElementById(pro).selected=true;
}
</script>
</head>
This is the table where I send my method.
<%
out.println("<table border=1>"
+ "<tr>"
+ "<th>ID</th>"
+ "<th>NOMBRE</th>"
+ "<th>PRECIO</th>"
+ "<th>PROVEEDOR</th>"
+ "</tr>");
for (Producto m:ar){
out.println("<tr>"
+ "<td>"+m.getIdproducto()+"</td>"
+ "<td>"+m.getNombreproducto()+"</td>"
+ "<td>"+m.getPrecio()+"</td>"
+ "<td>"+m.getPro().getNombreprov()+"</td>"
+ "<td>"
+ "<a href=javascript:llenar('"+m.getIdproducto()+"','"+m.getNombreproducto()+"',"
+ "'"+m.getPrecio()+"','"+m.getPro().getIdproveedor()+"')>Seleccionar</a>"
+ "</td>"
+ "</tr>");
}
out.println("</table>");
}catch(Exception e){}
%>
HTML of my form
<tr>
<td>ID:</td>
<td><input type="text" id="idd" name="id" readonly="readonly"></td>
</tr>
<tr>
<td>Nombre:</td>
<td><input type="text" id="nombree" name="nombre"></td>
</tr>
<tr>
<td>Precio:</td>
<td><input type="text" id="precioo" name="precio"></td>
</tr>
<tr>
<td>Proveedor:</td>
<td>
<select id="provv" name="prov">
<%
for(Proveedor m:ar1){
out.println("<option id='"+m.getIdproveedor()
+"' value='"+m.getIdproveedor()
+"'>"+m.getNombreprov()+"</option>");
}
%>
</select>
</td>
</tr>
If in one of the classes it has a data with a space, it does not add anything in any textbox.
But if in the classes that have String values, and do not have a space, if you add them in their respective textbox.
How can I do it so that I can add them if I put two names in a class?