0
Could someone help me with this code? I assume I do not understand about 80%, I am trying to popular the INFO div after selecting one of the options in the SELECT field, this information will be relative to the selected option, the information concerning the selected option is contained in the page example.php... As it is, it is working, however the information is being presented within an OPTION, I would like it at least to be populated within an INPUT
<html>
<head>
<title>Exemplo</title>
<script type="text/javascript" src="jquery.js"></script>
</head>
<body>
<label for="montadora">Montadora:</label>
<select name="montadora" id="montadora">
<option value="1">Fiat</option>
<option value="2">Ford</option>
<option value="3">Volkswagen</option>
</select>
<br />
<label for="veiculo">Veiculo:</label>
<select name="veiculo" id="veiculo"></select>
<div id="INFO">
</div>
<script type="text/javascript">
$(document).ready(function(){
$("#montadora").change(function(){
$.ajax({
type: "POST",
url: "exemplo.php",
data: {montadora: $("#montadora").val()},
dataType: "json",
success: function(json){
var options = "";
$.each(json, function(name, value){
options += '<option value="' + name + '">' + name + '</option>';
});
$("#veiculo").html(options);
}
});
});
});
</script>
</body>
</html>
Would you like to tell me how to delete JSON and use a normal query?? I don’t know how to use JSON
– ivan veloso
If with normal query you refer to loading HTML, you can use the jQuery Load. Simply inform where the loaded content will be placed. Something like:
$( "#INFO" ).load( "pagina.html" );
– Pedro Henrique