(SOLVED) radioButton ajax - El Forum - 02-27-2009
[eluser]jozeunico[/eluser]
I have this
Code: $(document).ready(function() {
$('#id_fondo').change(function() {
$.ajax({
type:"POST",
url:CI_ROOT+"index.php/usuario/busquedasimple/getAnios",
data: "id_fondo="+$('#id_fondo').val(),
success: function(data){
$('#radioBut').html(data);
}
});
});
});
$(document).ready(function() {
$(':radio').click(function() {
alert("hello");
$.ajax({
type:"POST",
url:CI_ROOT+"index.php/usuario/busquedasimple/manda",
data: "documentos="+$('#documentos').value(),
success: function(data){
$('#col').html(data);
}
});
});
});
And it works with dropdown and get data via ajax
I want to do something similar with a radio buttons, but even when I select from the dropdown the second function doesn't show de alert neither make de ajax request:
this is the function getAnios (first ajax request)
Code: function getAnios(){
$anios=$this->FondosModel->getAnios($_POST['id_fondo']);
echo "<td>De:".$anios['ani_inicio']." a ".$anios['ani_final']."</td>";
if($this->DocumentModel->anyDocument($_POST['id_fondo']>0)){
$attributes = array('name'=>'tipo',
'id'=>'documentos',
'value'=>1,
'checked'=>FALSE
);
echo"<td colspan='2'>".form_radio($attributes)."<label for='documentos'>Documentos</label>";
}else{
$attributes = array('name'=>'tipo',
'id'=>'documentos',
'value'=>1,
'checked'=>FALSE,
'enable'=>FALSE
);echo"<td colspan='2'>".form_radio($attributes)."<label for='documentos'>Documentos</label>";
}
if($this->FotografiasModel->anyPhoto($_POST['id_fondo']>0)){
$attributes = array('name'=>'tipo',
'id'=>'fotos',
'value'=>1,
'checked'=>FALSE
);
echo"<td colspan='2'>".form_radio($attributes)."<label for='fotos'>Fotografias</label>";
}else{
$attributes = array('name'=>'tipo',
'id'=>'fotos',
'value'=>1,
'checked'=>FALSE,
'enable'=>FALSE
);
echo"<td colspan='2'>".form_radio($attributes)."<label for='fotos'>Fotografias</label>>";
}
if($this->FotografiasModel->anyPostal($_POST['id_fondo']>0)){
$attributes = array('name'=>'tipo',
'id'=>'postales',
'value'=>1,
'checked'=>FALSE
);
echo"<td colspan='2'>".form_radio($attributes)."<label for='postales'>Postales</label></td>";
}else{
$attributes = array('name'=>'tipo',
'id'=>'postales',
'value'=>1,
'checked'=>FALSE, 'enable'=>FALSE
);
echo"<td colspan='2'>".form_radio($attributes)."<label for='postales'>Postales</label></td>";
}
}
(SOLVED) radioButton ajax - El Forum - 02-27-2009
[eluser]jozeunico[/eluser]
And here is my view
Code: <table id="busqueda">
<?php echo form_open('usuario/busqueda/do_validaCadena');
$attributes = array('name' => 'id_fondo',
'id' => 'id_fondo', );
$value[0]='todos';
foreach($fondos as $fondo){
$value[$fondo['id_fondo']]=$fondo['familia'];
}
echo "<tr><td>".form_dropdown('id_fondo',$value,0,"id='id_fondo'"). "</td></tr>";
echo "<tr id='radioBut'>";
$attributes =array('name'=>'tipo',
'id'=>'documentos',
'value'=>1,
'checked'=>true );
echo "<td>Año</td><td colspan='2'>".form_radio($attributes)."<label for='documentos'>Documentos</label>";
$attributes = array('name'=>'tipo',
'value'=>2,
'id'=>'fotos'
);
echo "".form_radio($attributes)."<label for='fotos'>Fotos</label>";
$attributes = array('name'=>'tipo',
'value'=>5,
'id'=>'postales'
);
echo "".form_radio($attributes)."<label for='postales'>Postales</label></td>";
echo "</tr>";
echo form_close(); ?>
</table>
How can i do another ajax request with the dropdowns that I get with the firs ajax request(dropdown)
Any help thank you and thanks for your time.
(SOLVED) radioButton ajax - El Forum - 03-02-2009
[eluser]jozeunico[/eluser]
I solved adding the click function at the new elements that I got with the the first ajax request.
|