I'm developing a template for a project and I needed to add images only if these images represent the place of the client's chairs and when the user clicks on any of those chairs the place is marked, only it is necessary to make that place marked is displayed on another page next to the other data of the form as name, password, etc. So:
Name: Java
Password: 123
Selected chair: 1 - A, (And other chairs if the user has chosen more than one)
Unlike the form, these images that represent the client's place are inside a div (making them easier to stylize them through CSS), and I came across the following error when I tried to create a variable in my PHP file so that it appears as other information entered by the user:
Notice: Undefined index: tCadeira1 in C:\xampp\www\teste\dados.php on line 54
"tCadeira1" was the variable I created in PHP. Now I'm not sure how to do this because I've tried to put the form tag closing after the div's, inside the div it's no use.
My HTML file:
<form action="dados.php" method="post">
<input type="text" id="cNome" name="tNome" title="Com no máximo 20 letras" size="20" maxlength="20" placeholder=" Digite Seu Nome"/>
<input id="submit" type="image" src="imagens/ButtonAceitar.png" />
<input type="reset" id="resetar" value="" />
</form>
<div id="cadeiras">
<img src="imagens/cadeiraAzul.png" name="tCadeira1" onClick="cor(this)">
<img src="imagens/cadeiraAzul.png" name="tCadeira2" onClick="cor(this)">
<img src="imagens/cadeiraAzul.png" name="tCadeira3" onClick="cor(this)">
<img src="imagens/cadeiraAzul.png" name="tCadeira4" onClick="cor(this)">
</div>
My PHP file:
<?php
$nome = $_POST["tNome"];
$cadeira = $_POST["tCadeira1"];
echo "$nome, obrigado por se cadastrar e comprar o seu ingresso em nosso site.<br>Cadeira(as) escolhida(as): $cadeira ";
?>
My JS file:
function cor(e) {
if (e.getAttribute("src") == "imagens/cadeiraAzul.png") {
e.setAttribute("src", "imagens/cadeiraPreta.png");
}
else {
e.setAttribute("src", "imagens/cadeiraAzul.png");
}
}
Show solutions with possible tag languages of this question, if possible.