-4
Good morning, guys, I have this job to do and deliver tomorrow at the junior college, but I’m completely lost on how to work this out at Notepad++. Could you please give me a light? I’ve been trying since 2:00 in the morning and I can’t. Thank you in advance.
Create an HTML form with javascript with the following fields:
Product value(text field); quantity(text field)
The program must calculate the total cost (quantity x product value);
The program should calculate the profit on each product (value of product x 65%);
The program should calculate the total profit (profit x quantity);
The program should calculate taxes on each product (product value + profit x 18.7%);
The program should calculate the total tax (taxes * quantity);
The program should calculate the selling price (value of the product + profit + taxes);
Print all calculations within a paragraph (< p >)
<title>Trabalho</title>
<script>
function calcularImposto(){
resultado = document.getElementById("resultado");
n1 = document.getElementById("n1").value;
imposto1 = parseFloat(n1)*0.22;
imposto2 = parseFloat(n1)*0.18;
resultado.innerHTML = "imposto 1" + imposto1 + "<br /> Imposto 2 " + imposto2;
}
</script>
</head>
<body>
<form>
<label>Número 1:</label>
<input type="text" name="n1" id="n1" size="5" />
<br />
<input type="button" name="botao" id="botao" value="Calcular" onclick="calcularSoma()" />
</form>
<p>Resultado: <span id="resultado"> 0 </span></p>
</body>
This is the code that the teacher passed as an example to help in the work itself. My question is on how to adapt this code for the exercises. I thought I’d do it with some variables like this:
var quantidade, produto
var lucro, imposto
var totalCusto, totalImposto, totalLucro
var precoVenda
custo total = quantidade * produto
lucro = (produto / 100) * 65
imposto = ((produto + lucro) / 100) * 18,7
totalLucro = lucro * quantidade
totalImposto = imposto * quantidade
precoVenda = produto + lucro + imposto
But I don’t know if it would work. I missed a few classes because of work and now I’m kind of desperate.
As for javascript, it’s to use jQuery, DOM, some other API, or whatever you want?
– Victor Stafusa
Victor, I must use the DOM.
– Rafael A.