-2
I’m making a system accessible to a visually impaired person and my biggest challenge is to make things accessible, on my Atualizar cliente
the person chooses the customer on the ID cliente
that returns a <select>
with all registered customers, what I would like to know is the following:
- How do I display a chosen person’s name on
ID cliente
to be displayed in the inputs below by the label tag known astitle=""
?
Example :
ID Cliente
has two clients: Leandro and MariaNome
has a legend tag calledtitle=""
that is written astitle="Campo para atualizar o nome de"
.- This one:
<p> Nome: <input type="text" name="nome" id="nome" title="Campo para atualizar o nome de" size=30 maxlength="30" required=""> </p>
- Every time I chose Leandro on
ID cliente
the tagtitle=""
in the inputNome
would showtitle="Campo para atualizar o nome de Leandro"
when I mouse this input. - Every time I picked Maria on
ID cliente
the tagtitle=""
in the inputNome
would showtitle="Campo para atualizar o nome de Maria"
when I mouse this input.
The image
The code
<!DOCTYPE html>
<html lang="pt-br">
<head>
<meta charset="utf-8">
<title> Atualizar cliente </title>
<link rel="stylesheet" href="/WEB/css/css.css">
<script>
function exibirNome() {
var nome = document.querySelector("#nome").value;
if (nome) {
alert(nome + " foi atualizado(a) com sucesso!");
}
}
</script>
</head>
<body>
<?php
require_once '../conexao/conexao.php';
if(isset($_POST['Atualizar'])){
$cd_cliente = $_POST['cd_cliente'];
$nome = $_POST['nome'];
try {
$atualizacao = "UPDATE cliente SET nome = :nome WHERE cd_cliente = :cd_cliente";
$atualiza_dados = $conexao->prepare($atualizacao);
$atualiza_dados->bindValue(':cd_cliente',$cd_cliente);
$atualiza_dados->bindValue(':nome',$nome);
$atualiza_dados->execute();
} catch (PDOException $falha_atualizacao) {
echo "A atualização não foi feita".$falha_atualizacao->getMessage();
}
}
// Query que seleciona chave e nome do cliente
$seleciona_nomes = $conexao->query("SELECT cd_cliente, nome FROM cliente");
// Resulta em uma matriz
$resultado_selecao = $seleciona_nomes->fetchAll();
?>
<form method="POST">
<p> ID cliente:
<select name="cd_cliente" required="" title="Caixa de seleção para escolher o cliente a ser atualizado">
<option value="" title="Opção vazia, escolha abaixo o cliente a ser atualizado"> </option>
<?php
foreach ($resultado_selecao as $valor) {
echo "<option value='{$valor['cd_cliente']}'>{$valor['nome']}</option>";
}
?>
</select>
</p>
<p> Nome: <input type="text" name="nome" id="nome" title="Campo para atualizar o nome de" size=30 maxlength="30" required=""> </p>
<p> <input type="submit" name="Atualizar" onclick="exibirNome()" title="Botão para confirmar a atualização do cliente" value="Atualizar cliente"> </p>
</form>
Tio, Error { "message": "Referenceerror: displayNome is not defined", "filename": "https://stacksnippets.net/js", "lineno": 1, "colno": 1 }
– user60252
Oops! Where is this?
– Sam
It’s there in the Ubmit input. I think it’s better that you take it, because this Ubmit won’t even influence the answer. Or take the function being called on the onclick from that button.
– Gato de Schrödinger
on run, choose client ID by clicking Update client and gives this error
– user60252
@Leocaracciolo But not pro Submit work in the same snippet not. It has to work only there in the author’s code of the question.
– Sam
Right, so why run it? Put the codes without this option to run
– user60252
@Leocaracciolo Run is to see the code working. When you select a name in select, the input title is changed, which is the heart of the matter.
– Sam
here only gives error
– user60252
the selected name does not go pro input
– user60252
@Leocaracciolo Where does the question say the name should go pro input? D
– Sam
So I didn’t understand the question, much less the answer. Cat’s does this
– user60252
@Leocaracciolo I understood the question. In the title says "How to display a person’s name within the title="" tag label that is in a <input> in a PHP form? [closed]" and in the middle says "How do I display the name of a person chosen in the client ID to be displayed in the inputs below by the label tag known as title=""?".. Note that in both he makes it clear that he wants the name to be displayed in the attribute (he called it "tag")
title
, and not the input itself.– Sam
You’re the guy, ATTRIBUTE and no tag. Now it’s good
– user60252
Leozão, the boy of the question just asked to put in the title of the same input. I put appearing in the input (also) just to give a plus of the answer and to show you how things happen. Rs
– Gato de Schrödinger
@sam is my master !
– Gato de Schrödinger
................ ;D
– Gato de Schrödinger
Interesting code.
– Fujjin