hallo ich möchte Daten von business3 Daten nach Business2 und Business2 Daten nach Business1 Dropdown-Liste, sondern auf Änderung() von Business1 Ich habe Daten als Antwort, aber habe ich nicht bekommen Sekunde bei Änderung() in Dropdown-Liste.auf Änderung funktioniert nicht in verschachtelten Dropdown-Liste
<!-- ajax code for first business starts here -->
<script>
$(document).on('change', 'select.Business1', function(){
var business1 = $('select.Business1 option:selected').val();
alert(business1);
var value = $(this).val();
$.ajax({
type:"POST",
data: { business1:business1 },
url: '<?php echo site_url('client_area/select_business_sub_cat'); ?>',
success : function (data){
$('#business2').empty();
$('#business2').append(data);
}
});
});
</script>
<!-- ajax code for first business ends here -->
// Dieses Skript nicht funktioniert. Ich kann das zweite Änderungsereignis nicht finden.
<!-- ajax code for second business starts here -->
<script>
$(document).on('change','#business2',function(){
alert('Change Happened');
});
</script>
<!-- ajax code for second business ends here -->
Ich habe auch mit Live() -Methode versucht, so auf dem ersten Drop-Down-Auswahl genannt aufmerksam und ruft dann der Ajax-Request fällt so zweite Füllungen nach unten (Alternate für die zweite Skript),
<script>
$(document).live('change', '#business2', function() {
alert('Change Happened');
});
</script>
Modellfunktion
public function select_business_sub_cat()
{
$business1 = $this->input->post('business1');
$result_sub_cat1 = $this->db->query("select category.id,subcategory.* From category LEFT JOIN subcategory ON category.id = subcategory.category_id where category.id = '$business1'");
$row_cat1 = $result_sub_cat1->result();
$data = array(
'id' => $row_cat1['0']->id,
'name' => $row_cat1['0']->name
);
echo "<option value='" . $row_cat1['0']->id . "'>" . $row_cat1['0']->name . "</option>";
// return $this->output->set_output($data);
}
View -
<div class="form-group">
<label>Business 1</label>
<select name="txtBusiness1" id="" style="height: 30px;width: 100%;" class="Business1">
<option value=""> Select Business </option>
<?php
$result_cat1 = $this->db->query("select * from category");
$row_cat1 = $result_cat1->result();
?>
<?php foreach($row_cat1 as $item){ ?>
<option value="<?php echo $item->id; ?>"><?php echo $item->name; ?></option>
<?php } ?>
</select>
</div>
<div class="form-group">
<label>Business 2</label>
<select name="txtBusiness2" id="business2" style="height: 30px;width: 100%;" class="Business2">
<option value=""> Select Business2 </option>
</select>
</div>
<div class="form-group">
<label>Business 3</label>
<select name="txtBusiness4" id="business3" style="height: 30px;width: 100%;" class="Business3">
<option value=""> Select Business3 </option>
<?php echo $abc; ?>
</select>
</div>
Ist das das Problem? 'Erfolg: Funktion (Daten) {' - sollte 'Erfolg' sein. * Rechtschreibfehler sind beim Codieren tödlich ...:) * – gibberish
Entschuldigung dafür, dass es irrtümlich Erfolg war, Rechtschreibung ist in meinem Code richtig. – Bhavin
Vielen Dank für die schnelle Antwort ... Ich habe erste Ajax-Antwort richtig Ich bin nicht auf Change Event der Dropdown-Liste erhalten erste Dropdown-Liste ist richtig mit Ajax gefüllt. und wenn ich die zweite Dropdown-Liste ändere, funktioniert das Ereignis on change nicht. – Bhavin