← PHP

Especie de calculadora

Lida 3068 vezes

Offline

asturmas 
Administrador
Mensagens 19734 Gostos 50
Feedback +2

Troféus totais: 39
Trófeus: (Ver todos)
Mobile User Windows User Super Combination Combination Topic Starter 100 Poll Votes 50 Poll Votes 10 Poll Votes Poll Voter Poll Starter

Alguem sabe como criar uma coisa deste genero que calcula preços mostrando-os automaticamente?

http://www.deleme.pt/estimativa_de_preco_files/main.htm

Cumps,
Offline

Júnio Branco 
Membro
Mensagens 563 Gostos 0
Feedback +2

Troféus totais: 28
Trófeus: (Ver todos)
Super Combination Combination Topic Starter 10 Poll Votes Poll Voter Level 5 Level 4 Level 3 Level 2 Level 1

Pelo que vi através do codigo fonte, é feito através de javascript.
Não sei se isto de ajuda: http://www.dreamincode.net/code/snippet392.htm
Offline

André Freitas 
Membro
Mensagens 941 Gostos 16
Troféus totais: 29
Trófeus: (Ver todos)
Apple User Super Combination Combination Topic Starter 10 Poll Votes Poll Voter Level 5 Level 4 Level 3 Level 2

Boas,
Aqui está da do género de como pretendes:

Código: [Seleccione]
<html>
<head>
<script language="Javascript">

function calcular(frm)
{
    frm.vfinal.value = 2 * frm.valor.value
     
}

</script>
</head>

<body>
<form>
Introduza o valor<input name="valor" onKeyUp="calcular(this.form)" type="text">
<br />
Resultado Final <input readOnly name="vfinal" />
</form>
</body>
</html>
Offline

Thomato 
Membro
Mensagens 4125 Gostos 3
Feedback +2

Troféus totais: 28
Trófeus: (Ver todos)
Apple User Super Combination Combination Topic Starter 10 Poll Votes Poll Voter Level 5 Level 4 Level 3 Level 2

André, nessa calculadora dá para fazer que seja o valor inserido mais 1?
Offline

André Freitas 
Membro
Mensagens 941 Gostos 16
Troféus totais: 29
Trófeus: (Ver todos)
Apple User Super Combination Combination Topic Starter 10 Poll Votes Poll Voter Level 5 Level 4 Level 3 Level 2

André, nessa calculadora dá para fazer que seja o valor inserido mais 1?
Sim, onde tem frm.vfinal.value = 2 * frm.valor.value substituir por frm.vfinal.value = parseInt(frm.valor.value) + 1
Offline

Thomato 
Membro
Mensagens 4125 Gostos 3
Feedback +2

Troféus totais: 28
Trófeus: (Ver todos)
Apple User Super Combination Combination Topic Starter 10 Poll Votes Poll Voter Level 5 Level 4 Level 3 Level 2

Ah, eu tinha posto 1 + no início :s

EDIT: Vai dar ao mesmo... Eu coloco 1 e fica 11... Coloco 2 e fica 21  :lol:
Offline

André Freitas 
Membro
Mensagens 941 Gostos 16
Troféus totais: 29
Trófeus: (Ver todos)
Apple User Super Combination Combination Topic Starter 10 Poll Votes Poll Voter Level 5 Level 4 Level 3 Level 2

Desculpa Thomato, ele assim estava a adicionar como fosse string, tem de ficar frm.vfinal.value = parseInt(frm.valor.value) + 1

parseint faz com que a variável valor seja vista como inteiro e não como string.
Offline

Thomato 
Membro
Mensagens 4125 Gostos 3
Feedback +2

Troféus totais: 28
Trófeus: (Ver todos)
Apple User Super Combination Combination Topic Starter 10 Poll Votes Poll Voter Level 5 Level 4 Level 3 Level 2

Obrigado. Resultou :)
Offline

asturmas 
Administrador
Mensagens 19734 Gostos 50
Feedback +2

Troféus totais: 39
Trófeus: (Ver todos)
Mobile User Windows User Super Combination Combination Topic Starter 100 Poll Votes 50 Poll Votes 10 Poll Votes Poll Voter Poll Starter

Vou testar obrigado