I'm learning php and tried something I do in ASP.NET but it's not rolling. I have a page that receives values from a previous page via _GET. In it I have input of the radio type that I want, that when clicking on a submit, the selected radio turns red. the problem is that by clicking submit, the previously received value is lost, so the page does not load. How to do this without losing the amount received?
The code structure is:
html head body form
Code php:
?php
define('__ROOT__', dirname(dirname(__FILE__)));
require_once(__ROOT__ . '<script type="text/javascript">
document.getElementById("submit").onclick = function() {
var radios = document.getElementsByName("0");
for (var i = 0; i < radios.length; i++) {
if (radios[i].checked) {
$('input:radio').css('background','#000');
console.log("Escolheu: " + radios[i].value);
}
}
};
</script>
<input id="submit" type="submit">
- Apresentação\Controller\PerguntaController.php');
require_once(__ROOT__ . '?php
define('__ROOT__', dirname(dirname(__FILE__)));
require_once(__ROOT__ . '<script type="text/javascript">
document.getElementById("submit").onclick = function() {
var radios = document.getElementsByName("0");
for (var i = 0; i < radios.length; i++) {
if (radios[i].checked) {
$('input:radio').css('background','#000');
console.log("Escolheu: " + radios[i].value);
}
}
};
</script>
<input id="submit" type="submit">
- Apresentação\Controller\PerguntaController.php');
require_once(__ROOT__ . '%pre% -Apresentação\Controller\RespostaController.php');
$Disciplina=$_GET["pergunta"];
$Perguntacontroller = new PerguntaController();
$retorno = $Perguntacontroller->Carregar($Disciplina);
$Respostacontroller = new RespostaController();
$x = 0;
while ($linha1 = mysqli_fetch_array($retorno)) {
$y=0;
$Pergunta = $linha1["pergunta"];
$Id[$x] = $linha1["Id"];
$certa[$x]=$linha1["certa"];
$retornoR = $Respostacontroller->Carregar($Id[$x]);
echo "$Pergunta<br /><br />";
while ($linha2 = mysqli_fetch_array($retornoR)) {
$Resposta = $linha2["Resposta"];
echo"<input type=\"radio\" name=$x value=$y >$Resposta <br /><br />";
echo"<input type=\"hidden\" name=$x value=$certa[$x]>";
$y++;
}
$x++;
}
?>
-Apresentação\Controller\RespostaController.php');
$Disciplina=$_GET["pergunta"];
$Perguntacontroller = new PerguntaController();
$retorno = $Perguntacontroller->Carregar($Disciplina);
$Respostacontroller = new RespostaController();
$x = 0;
while ($linha1 = mysqli_fetch_array($retorno)) {
$y=0;
$Pergunta = $linha1["pergunta"];
$Id[$x] = $linha1["Id"];
$certa[$x]=$linha1["certa"];
$retornoR = $Respostacontroller->Carregar($Id[$x]);
echo "$Pergunta<br /><br />";
while ($linha2 = mysqli_fetch_array($retornoR)) {
$Resposta = $linha2["Resposta"];
echo"<input type=\"radio\" name=$x value=$y >$Resposta <br /><br />";
echo"<input type=\"hidden\" name=$x value=$certa[$x]>";
$y++;
}
$x++;
}
?>
Java script code:
%pre%