0
I have the following HTML, but all on the same page id entree is where it takes my input field from the address typed arrival is where he gets his final address outworking is the calculation:
<div id="entrada"></div>
<div id="chegada"></div>
<div id="Resultado"></div>
<input type="submit" class="btn-green" id="btnCalcular" onclick="calcular();" value="Calcular" />
I have this Function to calculate my input text:
<script language= "javascript">
function calcular(){
var litros = parseFloat(document.getElementById('txtKM').value) / parseFloat(document.getElementById('txtKML').value);
var valor = parseFloat(document.getElementById('txtPL').value) * litros;
document.getElementById('Resultado').innerHTML = "<br><b>Gasto total: R$ </b>" + valor;
var txtentrada = document.getElementById('txtEnderecoPartida').value;
document.getElementById('entrada').innerHTML = "<br><b>Endereço de Partida:</b><br>" + txtentrada;
var txtchegada = document.getElementById('txtEnderecoChegada').value;
document.getElementById('chegada').innerHTML = "<br><b>Endereço de Chegada:</b><br>" + txtchegada;
}
</script>
Now, what I’d like to know is: How do I stop at the time of clicking the button it can open on another page (Poup-up), already tried with windows.open but does not open, since my onclick is calling this function on the same page to calculate.
EDIT: I have this HTML:
<a href="index.php" onclick="window.open('index.php', 'Pagina', 'STATUS=NO, TOOLBAR=NO, LOCATION=NO, DIRECTORIES=NO, RESISABLE=NO, SCROLLBARS=YES, TOP=10, LEFT=10, WIDTH=900, HEIGHT=500');">
I wanted to pull the information from outworking to a new page;
For the pop-up you need to pass an additional parameter, have you tried?:
window.open ('popup.html', 'popup')
– David Dias
Note that the browser blocks pop, need to release the first time.
– David Dias
And to send the result to the new page in the pop-up, you can pass via get or post. via get would be simple:
window.open ('index.php?par1=2&par2=3', 'popup')
– David Dias
Put all html if given, ta kind of confused. Where are these elements with id txtKM and txtPL?
– LeAndrade
Leandro, this would be my inputs with the respective ids to take the distance in km, fuel consumption in km and fuel price to at the end click the calculate button and get the result, so when clicking it shows on the page and was quenrendo open in a new window (Pou-up).
– Jean Alves