Jump to content

Preciso Ajuda


amilcar
 Share

Recommended Posts

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

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 by tiago.f
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.