Simple snippet copied and pasted from here, why not working?
Hello,
I am replacing the whole stuff by something that I (finally) managed it to make it work. Yet, I have some doubts about this. My problem is that I am not loading that document value that you see, which is the index of the first dropdown list to a controller (I am working in an MVC env). So I introduced this extra callback function to see what happened, but, actually, I think this callback is not telling me anything, or is it? when I move the select box it does get executed, but why am I not getting anything in my controller file (where I have the code to fetch it).
The extra function that pops the alert box actually gets executed if I move the select list but that does not mean that the value is actually loaded to the controller.
Aside from this, I cannot get the code properly formatted here! even though i am clicking on "add code" so it looks very ugly
- <script src="http://code.jquery.com/jquery-latest.js"></script>
<script type="text/javascript">
//jquery code for source list
$(document).ready(function()
{
$('#country').change(function()
{
if ($(this).val()!='')
{
$("#source").load("/CI-3/application/controllers/control_form.php/",{pais_id: $(this).val()}, function() {
alert('Load was performed.')});
}
});
}); // end of first function
</script>
</head>
<body>
<?php echo form_open('control_form/add_all'); ?>
<label for="country">Country<span class="red"></span></label>
<select id="country" name="country">
<option value="">Select</option>
<?php
foreach($result as $row)
{
echo '<option value="' . $row->pais_id . '">' . $row->pais_name . '</option>';
}
?>
</select>
<label for="source">Source Language<span class="red"></span></label>
<!--this will be filled based on the tree selection above-->
<select id="source" name="source">
<option value="">Select</option>
<?php
foreach($source as $row)
{
echo '<option value="' . $row->id_from . '">' . $row->from_name . '</option>';
}
?>
</select>
<?php echo form_close(); ?>