I am making a screen that adds images to the database and after doing so, I list them by adding a text box in which I am going to capture their DESCRIPTION, example:
<form>
<input id="1" name="ftp_desc" maxlength="256" placeholder="Añade una descripción" required="required" type="text">
<input id="2" name="ftp_desc" maxlength="256" placeholder="Añade una descripción" required="required" type="text">
<input id="3" name="ftp_desc" maxlength="256" placeholder="Añade una descripción" required="required" type="text">
</form>
<a type="button" onclick="javascript: agregarPasoDieciseis()">Finalizar</a>
JavaScript
function agregarPasoDieciseis() {
var descripcion = document.getElementsByName("ftp_desc").value;
alert(descripcion);
}
As I get the ID and the VALUE of the input with Javascript, the previous code did not work for me.
getElementsByName
It returns a set of objects with the nameftp_des
, you have to access them through a loop as if it were an array and thus obtain their id and value attributes.