Usamos cookies para medir audiência e melhorar sua experiência. Você pode aceitar ou recusar a qualquer momento. Veja sobre o iMasters.
ola galera!! fmz?
tenho o seguinte codigo:
function buscaPreco(prc) { var id = document.regPedido.produtos.selectedIndex; if(id<=0) { document.getElementById('prcUnit').innerHTML = ' '; } else { document.getElementById('prcUnit').innerHTML = prc; document.regPedido.prc.value = prc }}function valorTotal () { var a = document.regPedido.quantidade.value; var prc = document.getElementById('prcUnit').innerHTML; if(a=0) { document.getElementById('prcTotal').innerHTML = ' '; } else { if(prc = 0) { document.getElementById('prcTotal').innerHTML = ''; }else{ document.getElementById('prcTotal').innerHTML = prc * a; }}}a funcao buscaPreco() faz o seguinte, como o proprio nome ja diz, busca o preco, até ai beleza, funciona direitinho!!
no meu html tem um campo pro usuario digitar a quantidade, ai essa "quantidade" vai multiplicar o resultado da funcao buscaPreco() e com isso dar um valor total!!
mas o que retorna é zero!! ñ entendo porq!!!
olha o html:
<?phpinclude("estrutura/top.php");$id = $_REQUEST['id'];require_once("../arquitetura/bd.class.php");$bd = new bd;$sql = "SELECT * FROM produto ORDER BY ID LIMIT 1,14";$sql = $bd->Exe($sql);$sql2 = "SELECT * FROM enderecos WHERE ID_cad = '$id'";$sql2 = $bd->Exe($sql2);?><form name="regPedido" id="regPedido"><table cellspacing="3" id="ContUSUARIO" style="display: block;"> <tr> <th>Produto/Serviço</th> <th>Quantidade</th> <th>prc Unitário</th> <th>prc Total</th> <th>Local de Entrega</th> </tr> <tr> <td> <select name="produtos" id="produtos"> <option value="-1">Selecione o Serviço</option> <?php while ($ret = mysql_fetch_array($sql)){ echo "<option value='".$ret['ID']."' onclick=\"buscaPreco('".$ret['Valor']."')\">".$ret['Produto']."</option>"; } ?> </select> </td> <td><input type="text" name="quantidade" id="quantidade" size="7" maxlength="5" onkeyup="valorTotal();"/></td> <td id="prcUnit" align="center"></td> <td id="prcTotal" align="center"></td> <td> <select id="locEntrega" name="locEntrega"> <option value="-1">Selecione o Endereço de Entrega</option> <?php while ($r = mysql_fetch_array($sql2)){ echo "<option value='".$r['ID']."'>".$r['End_comp']." nº.:".$r['Numero']." - ".$r['Cidade']." - ".$r['Estado']."</otion>"; } ?> </select> </td> </tr></table></form>
se vcs souberem, agradeco!!!
*editei, pois eu tinha feito um teste e tava a funcao de teste!! ehhehe!!! agora o cidigo do html esta certo, ma ainda continua aparecendo zero!!
Carregando comentários...