1
I have a form. When I press the Send button, the function checks the information.
In case everything is ok, I would like to make a checkbox packed table.
The table would have (arrows) rows and (Rels + cycles) columns. In each cell, I would like to place the checkbox.
Unfortunately, I tried a few posts and did not succeed. Any help is welcome. Thank you very much!
function Enviar() {
var flechas = document.getElementById("flechasid");
var rels = document.getElementById("relsid");
var ciclos = document.getElementById("ciclosid");
if (flechas.value > 0 && flechas.value < 30 && ciclos.value > 0 && ciclos.value < 10 && rels.value > 0 && rels.value < 20) {
alert('Os seus dados foram encaminhados com sucesso!');
} else {
alert('Informações inválidas!');
};
}
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="Aprenda a criar PHIAs">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<script src="app.js"></script>
<form name="Untitled-2">
<fieldset>
<legend>
Número de relações do tipo 3
</legend>
<table cellspacing="3">
<tr>
<td>
<label for="rels">
Relações
</label>
</td>
<td align="left">
<input type="text" name="rels" id="relsid" required="required" placeholder=0>
</td>
</tr>
</table>
</fieldset>
<fieldset>
<legend>
Número de flechas nessas relações
</legend>
<table cellspacing="3">
<tr>
<td>
<label for="flechas">
Flechas
</label>
</td>
<td align="left">
<input type="text" name="flechas" id="flechasid" required="required" placeholder=0>
</td>
</tr>
</table>
</fieldset>
<fieldset>
<legend>
Número de ciclos elementares
</legend>
<table cellspacing="3">
<tr>
<td>
<label for="ciclos">
Ciclos
</label>
</td>
<td align="left">
<input type="text" name="ciclos" id="ciclosid" required="required" placeholder=0>
</td>
</tr>
</table>
</fieldset>
<input type="button" onclick="Enviar();" value="Enviar">
<input type="reset" value="Limpar">
</form>
<div id="test"></div>
</body>
</html>
Thank you @Sergio . I’m new to programming but managed to implement your response to my situation. I don’t know if I’m going to need further to understand the syntax of
data.celulas.forEach(function (celula) {});
, So far it worked. I had to have written what I’m going to do with the table. But you got it right, I’ll create another function using the information from each cell. So I need a name for each cell according to the table position. A detail, any hint in the question title is welcome.– Vasco
@Vasco joined explanation about
data.celulas.forEach(function (celula) {});
. I’m glad I could help.– Sergio