0
I am trying to use the onSearch event by calling a function of my Js file where, when searching for a specific term (TJ RJ), it will display an image, only that the image is not displayed after giving the enter. PS: The image is in the root folder, next to the html file.
Follow the Cód:
HTML:
<!DOCTYPE html>
<html lang="pt-BR">
<head>
<meta charset="utf-8">
<title>DETRAN</title>
<style>
body {
background: #1d1f21b0;
font: normal, 15pt, arial;
text-align: center;
}
header {
color: white;
text-align: center;
}
section {
background: white;
border-radius: 10px;
padding: 15px;
width: 500px;
height: 300px;
margin: auto;
box-shadow: 5px 5px 10px #424141b0;
}
footer {
color: white;
text-align: center;
font-style: italic;
}
</style>
<script type="text/javascript" src="js/ex007.js"></script>
</head>
<body >
<!-- MÓDULO C - AULA 13 [exercícios] -->
<header>
<h1>Conteúdo Programático</h1>
</header>
<section>
<div>
<strong>Informe o Concurso:</strong><br>
<input id="orgao" type="search" onsearch="carregar()">
</div>
<br><br>
<div>
<img id="imagem" src="" alt="Concurso">
</div>
</section>
<footer>
<p>© RTR</p>
</footer>
</body>
</html>
Js:
function carregar(){
var conc = document.getElementById('orgao')
var img = document.getElementById('imagem')
if(conc == "TJ RJ"){
img.src = 'tjrj.png'
}
}
This onsearch event is not supported by firefox or edge https://www.w3schools.com/jsref/event_onsearch.asp.
– Benilson