0
Hello, I’m learning Javascript and I have a question. I already know about HTML, CSS and SQL
Which languages I need to create a system (stock control) that adds, alters (already added) and deletes, element through internal search on the site with javascript.
I also want to store the client’s data in the client-side so that it can open the saved data in your system, which it already has, and can be stored in portable storage.
I already have a code
<!DOCTYPE html>
<html lang="pt-br">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Evento de Botão</title>
<style>
input, button {
padding: .5em;
}
table {
border-collapse: collapse;
margin-top: 1em;
width: 100%;
}
th, td {
border: 1px solid #bbb;
padding: 5px;
text-align: left;
}
</style>
</head>
<body>
<input type="text" id="codigo" placeholder="insira o codigo do produto">
<input type="text" id="precoCompra" placeholder="preco de compra">
<input type="text" id="precoVenda" placeholder="preco de venda">
<button id="btn-adicionar">
Adcionar
</button>
<button id="btn-alterar">
Alterar
</button>
<div id="pesquisa" hidden>
<input type="text" placeholder="pesquise o codigo" id="campoPesquisa">
</div>
<table id="dados" hidden>
<thead>
<tr>
<th>Codigo do Produto</th>
<th>preço compra</th>
<th>preço Venda</th>
<th>lucro</th>
</tr>
</thead>
<tbody></tbody>
</table>
<script>
const codigo = document.querySelector('#codigo')
const precoCompra = document.querySelector('#precoCompra')
const precoVenda = document.querySelector('#precoVenda')
const btn = document.querySelector('#btn-adicionar')
const dados = document.querySelector('#dados')
const btnAlterar = document.querySelector('#btn-alterar')
const tbody = document.querySelector('tbody')
const pesquisa = document.querySelector('#pesquisa')
const campopesquisa= document.querySelector('#campoPesquisa')
codigo.focus()
btn.addEventListener('click', e=>{
let compra = +precoCompra.value
let venda = +precoVenda.value
let valorFinal = 0
if (compra && venda && codigo){
valorFinal = venda - compra
dados.removeAttribute('hidden')
tbody.innerHTML += `<tr>
<td class="codproduto">${codigo.value}</td>
<td>${compra}</td>
<td>${venda}</td>
<td>${valorFinal}</td>
</tr>`
codigo.value = ''
precoCompra.value = ''
precoVenda.value = ''
codigo.focus()
}
})
btnAlterar.addEventListener('click', e=>{
/*
if(tbody){
pesquisa.removeAttribute('hidden')
let search = campopesquisa.value
}
*/
pesquisa.removeAttribute('hidden')
for( let c of document.querySelectorAll(".codproduto") )
{
console.log(c.innerHTML)
}
})
</script>
</body>
</html>
You will need to have a good javascript bag. To optimize your work you can use some framework like reactjs. To store data in client-side you can use some library as sql.js
– Miguel Neto
I’m still at Home more I learn fast, I’ll take a look at reactjs
– Otávio Guilherme
Good evening, I currently work in a carrier system company and I already have enough experience and baggage in this type of system, the most correct and safe way is you work with java in the back end and use a database ( in my case use and prefer the postgres ), recommend you study a little and understand the functioning of Servlet and the MVC standard, about where and when to treat business rule and stuff like, so you will have a stable and secure system.
– Mateus Veloso
Thank you very much I will follow your tip
– Otávio Guilherme