amilcar Posted January 22, 2016 at 06:01 PM Report Share #592350 Posted January 22, 2016 at 06:01 PM Agradecia ajuda como multiplicar valores selecionados em 2 menus dropdown. Exemplo : 1º Menu <html> <body> <form> <select name="Quantidade"> <option value="" selected> <option value="1">1 <option value="2">2 <option value="3" >3 <option value="4" >4 <option value="5">5 </select> </form> </body> </html> 2º Menu <html> <body> <form> <select name="Preço"> <option value="" selected> <option value="2,50">2,50 <option value="3,00">3,00 <option value="150,00" >150,00 <option value="220,00" >220,00 <option value="300,00">300,00 </select> </form> </body> </html> Pretendia a multiplicação de 1 item do Menu Quantidade pelo outro item do Menu Preço. Obrigado Link to comment Share on other sites More sharing options...
tiago.f Posted January 22, 2016 at 09:32 PM Report Share #592371 Posted January 22, 2016 at 09:32 PM Oi, E queres fazer isso como exactamente? Com Javascript? Com alguma linguagem "server-side" tipo php, asp, etc? É que com html puro não me parece que dê.... Link to comment Share on other sites More sharing options...
amilcar Posted January 26, 2016 at 04:00 PM Author Report Share #592567 Posted January 26, 2016 at 04:00 PM Obrigado pelo contacto, pode ser em Javascript. O objectivo é colocar num site do Webacappella - caixa HTML. Link to comment Share on other sites More sharing options...
tiago.f Posted January 26, 2016 at 04:46 PM Report Share #592578 Posted January 26, 2016 at 04:46 PM Certo, e o resultado é suposto aparecer onde? Link to comment Share on other sites More sharing options...
amilcar Posted January 26, 2016 at 10:08 PM Author Report Share #592590 Posted January 26, 2016 at 10:08 PM Na própria página, obrigado pela atenção tipo Quant * Preço = TOTAL Link to comment Share on other sites More sharing options...
tiago.f Posted January 26, 2016 at 10:14 PM Report Share #592591 Posted January 26, 2016 at 10:14 PM Olá, Posso assumir então então que os dois "menus" estão na mesma página? (É que no exemplo inicial mostras 2 menus cada um na sua página... Link to comment Share on other sites More sharing options...
amilcar Posted January 27, 2016 at 10:12 AM Author Report Share #592597 Posted January 27, 2016 at 10:12 AM Olá Os dois menus estão na mesma página, eu explico. No meu site: http://www.xarazarte.pt pretendo colocar um link para uma pagina, que só eu tenho acesso, para fazer notas de encomenda. Obrigado pela atenção Amilcar Link to comment Share on other sites More sharing options...
tiago.f Posted January 27, 2016 at 12:10 PM Report Share #592601 Posted January 27, 2016 at 12:10 PM (edited) queres qq coisa como isto então: <html> <head> <script> function mult() { var d1 = document.getElementById('preco'); var d2 = document.getElementById('quantidade'); var total = d1.options[d1.selectedIndex].value * d2.options[d2.selectedIndex].value; document.getElementById("resultado").innerHTML = total; } </script> </head> <body> <form> <select name="Quantidade" id="quantidade" onchange="mult();"> <option value="" selected> <option value="1">1</option> <option value="2">2</option> <option value="3" >3</option> <option value="4" >4</option> <option value="5">5</option> </select> </form> <form> <select name="Preço" id="preco" onchange="mult();"> <option value="" selected> <option value="2.50">2,50</option> <option value="3.00">3,00</option> <option value="150.00" >150,00</option> <option value="220.00" >220,00</option> <option value="300.00">300,00</option> </select> </form> <div id="resultado" </body> </html> Edited January 27, 2016 at 12:11 PM by tiago.f Link to comment Share on other sites More sharing options...
amilcar Posted January 27, 2016 at 12:29 PM Author Report Share #592602 Posted January 27, 2016 at 12:29 PM Muito agradecido Pergunto-lhe só se é possível ficar tudo em linha: 24 x 2,50 = 60,00 Para eu depois compor a apresentação no WebAcappella Amilcar Link to comment Share on other sites More sharing options...
tiago.f Posted January 27, 2016 at 03:25 PM Report Share #592611 Posted January 27, 2016 at 03:25 PM Sim, é só alterares a linha que associa o valor ao innerHTML Link to comment Share on other sites More sharing options...
amilcar Posted January 27, 2016 at 04:04 PM Author Report Share #592623 Posted January 27, 2016 at 04:04 PM Ok, vou tentar Agradecido Amilcar Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now