Welcome Guest, Not a member yet? Register   Sign In
[solved] Jquery + form Helper - Newbie question
#1

[eluser]Juan Velandia[/eluser]
Hello Everyone, I'm starting with Jquery and I'm trying to hide a div when a user checks a radio button, and as this is my first jquery code within Codeigniter I'm having some issues:

this is in the view
Code:
<div class="div_to_hide">
This must be hidden!
  </div>


this is the javascript in &lt;head&gt;
Code:
$(document).ready(function() {
    $("#person").click(function(){
          $('div.div_to_hide').hide();
         alert("HELLO this works!");
        });

And heres the radio button with the form helper format
Code:
&lt;? $js1 = 'onClick="$('div.hide').hide();"'; ?&gt;
Persona:&lt;?php echo form_radio('#person', 'Natural', TRUE, $js1 ); ?&gt;

Any Ideas?. Thanks a lot, Any suggestion will be highly appreciatted.
#2

[eluser]Juan Velandia[/eluser]
I've made it work!:

The JS code:
Code:
$("#radio_button1").click(function(){
          $('div.hide').show();
        });  


    $("#radio_button2").click(function(){
          $('div.hide').hide();
        });

the HTML:
Code:
&lt;?$js1 = 'id="radio_button1"'; ?&gt;
Soy persona Natural&nbsp;&lt;?php echo form_radio('tipo_persona', 'Natural', TRUE, $js1); ?&gt;


&lt;?$js2 = 'id="radio_button2"'; ?&gt;
Soy persona Juridica&nbsp;&lt;?php echo form_radio('tipo_persona', 'Juridica', FALSE, $js2); ?&gt;


<div class="hide">
This shows/hides when radiobutton is clicked
</div>




Theme © iAndrew 2016 - Forum software by © MyBB