1
So, guys, I’m new to the site and I’m in urgent need of some help. I’m creating a site where the person selects origin city and destination city so far so good, I want that when the person select these two options and click on the value of the passage, show a value, but I bumped heads pakas trying to do the javascript for this, if anyone can help I am very grateful
<script>
function passagem(){
var sel_origem = document.getElementById("item1");
var sel_destino = document.getElementById("item2");
if (item1 = ori_poa & item2 = dest_fln){
var resultado = 200;
}
else{
resultado = 0;
}
}
alert("Valor da Passsagem: " + resultado)
</script>
<select name="origem" id="item1">
<option value="sel_ori">Selecione a Cidade Origem</option>
<option value="ori_poa">Porto Alegre</option>
<option value="ori_fln">Florianópolis</option>
<option value="ori_cwb">Curitiba</option>
<option value="ori_gru">São Paulo</option>
<option value="ori_sdu">Rio de Janeiro</option>
<option value="ori_vix">Vitória</option>
<option value="ori_bsb">Brasília</option>
<option value="ori_cnf">Belo Horizonte</option>
<option value="ori_gyn">Goiania</option>
<option value="ori_for">Fortaleza</option>
<option value="ori_mcz">Maceió</option>
<option value="ori_mao">Manaus</option>
<option value="ori_rec">Recife</option>
</select>
<select name="destino" id="item2">
<option value="sel_dest">Selecione a Cidade Destino</option>
<option value="dest_poa">Porto Alegre</option>
<option value="dest_fln">Florianópolis</option>
<option value="dest_cwb">Curitiba</option>
<option value="dest_gru">São Paulo</option>
<option value="dest_sdu">Rio de Janeiro</option>
<option value="dest_vix">Vitória</option>
<option value="dest_bsb">Brasília</option>
<option value="dest_cnf">Belo Horizonte</option>
<option value="dest_gyn">Goiania</option>
<option value="dest_for">Fortaleza</option>
<option value="dest_mcz">Maceió</option>
<option value="dest_mao">Manaus</option>
<option value="dest_rec">Recife</option>
</select>
</p>
<p><input name="Enviar" type="submit" value="Valor Passagem" onclick="passagem()"/>
</p>
<p><input name="Limpar" type="reset" value="Limpar"/>
Why not use Jquery with change event ?
– Matheus Miranda
I would, but I didn’t have classes yet using Jquery and the job is to do in the sublime or Notepad where you do html/css and javascript together
– Vinícius Araújo