alves077 Posted August 4, 2013 at 06:50 PM Report #520817 Posted August 4, 2013 at 06:50 PM (edited) Boa tarde, Estou de volta de um problema que está complicado de resolver. Já tentei de algumas formas mas não saiu do mesmo.. Tenho o seguinte código: $(document).ready(function() { $("#select1").on('change', function() { //.... }); $("#botao_actualiar").on('click', function() { var selecionado = 2; $("#select_js").html("<select id='select1' name='select1' ><option> Load </option></select>"); $.post("teste.php", {select1: teste}, function(resposta) { $("#select_js").empty(); $("#select_js").append(resposta); selecionado = $("#select_gas option:selected").val(); $("#select_gas").val(selecionado).trigger('change'); $("#nome_tarifario_gas").empty(); $("#select_gas").trigger("change"); }); }); O select_js é uma div que esta a cobrir o select1 No teste.php tenho $sql="SELECT....."; $query_1=mysql_query($sql) or die(mysql_error()); echo("<select id='select1' name='select1' >"); while($row = mysql_fetch_array($query_1)) { echo("<option value='". $row['nome']."' selected>".$row['nome']."</option>"); } echo("</select>"); Ele faz bem o append, mas depois nunca mais funciona o change do select1. Pensava que teria que actualizar o DOM, para isso usei a função on, mas continuo com o mesmo problema. Alguém consegue dar uma ideia do problema? Obrigado pela atenção, alves077 Edited August 4, 2013 at 06:51 PM by alves077
yoda Posted August 4, 2013 at 07:12 PM Report #520818 Posted August 4, 2013 at 07:12 PM Em vez de devolveres no PHP o select todo, experimenta devolver apenas as opções. before you post, what have you tried? - http://filipematias.info sense, purpose, direction
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