Welcome Guest, Not a member yet? Register   Sign In
Radio button
#11

[eluser]hujan[/eluser]
so it that mean i don't need to have sap_yes,sap_no,sponser and my_sponser in my sap table column? and just replace 1) sap_yes and sap_no to sap_radio1 2)sponser and my_sponser to sap_radio2?

#12

[eluser]hujan[/eluser]
i have rename my fields to sap_radio1 and sap_radio2...after i submitted the form, the radio button process does not get inserted into database, it only give me 0 for sap_radio1 and sap_radio2 fields.
#13

[eluser]noslen1[/eluser]
Well it's hard to say when we don't know what the logic is, what you're trying to store and everything.

What I can conclude from reading your posts is that you have in your form 2 radio buttons, with for each 2 possible data
- sap_radio
- Yes
- No
- sponser_radio
- Sposer
- No

So in your database I think you should have 2 fields :
- sap (BOOL), that can be TRUE or FALSE
- sponser (VARCHAR), that can be 'Sposer' or 0, NULL... anything else

Is that the behaviour expected ?
#14

[eluser]hujan[/eluser]
in my form i have 4 radio buttons which are sap_yes, sap_no, sponser and my_sponser.
sap_yes and sap_no indicate Yes and No resp.
sponser and my_sponser will get Sponser and Half sponser.

i have changed my sap table fields to sap_radio2(this field is to store Yes or No) and sap_radio2(this field is to store Sponser and Half sponser)
ie: sap_radio1
-sap_yes
-sap_no

sap_radio2
-sponser
-my_sponser
#15

[eluser]noslen1[/eluser]
Okkkkk then, change both of your fields type sap_radio1 and sap_radio2 in your database to VARCHAR(16).

Change your form view to :
Code:
<p>
    &lt;input id="sap_yes" type="radio" name="sap_radio1" value="yes" &lt;?php echo set_radio('sap_radio', 'yes'); ?&gt; /&gt;
    <label for="sap_yes">Yes</label>
        
    &lt;input id="sap_no" type="radio" name="sap_radio1" value="no" &lt;?php echo set_radio('sap_radio', 'no'); ?&gt; /&gt;
    <label for="sap_no">No</label>
</p>

<p>
    &lt;input id="sponser" type="radio" name="sap_radio2" value="sponser" &lt;?php echo set_radio('sap_radio2', 'sponser'); ?&gt; /&gt;
    <label for="sponser">Sponser</label>
        
    &lt;input id="halfsponser" type="radio" name="sap_radio2" value="half_sponser" &lt;?php echo set_radio('sap_radio2', 'half_sponser'); ?&gt; /&gt;
    <label for="halfsponser">Half Sponser</label>
</p>


Then in your model :

Code:
$data = array(
    'sap_radio1' => $this->input->post('sap_radio1'),
    'sap_radio2' => $this->input->post('sap_radio2')
);

You should approach the final result
#16

[eluser]hujan[/eluser]
my mistake..i re-write my code already to

in view:
Code:
<p>
&lt;input type="radio" name="sap_radio1" value="sap_yes" &lt;?php echo set_radio('sap_radio1', '1'); ?&gt; /&gt;
<label for="sap_yes">Yes</label>
        
&lt;input type="radio" name="sap_radio1" value="sap_no" &lt;?php echo set_radio('sap_radio1', '2'); ?&gt; /&gt;
<label for="sap_no">No</label>
</p>

<p>
&lt;input type="radio" name="sap_radio1" value="sponser" &lt;?php echo set_radio('sap_radio2', '1'); ?&gt; /&gt;
<label for="sponser">Sponser</label>

&lt;input type="radio" name="sap_radio2" value="my_sponser" &lt;?php echo set_radio('sap_radio', '2'); ?&gt; /&gt;
<label for="my_sponser">Half Sponsor</label>
</p>

in model:
Code:
$data = array('sap_radio1'=>$this->input->post('sap_radio1'),
      'sap_radio2'=>$this->input->post('sap_radio2'));
             $this->db->insert('sap',$data);

when i submitted the form I still get 0 value in sap_radio1 and sap_radio2 column inside the sap table
#17

[eluser]noslen1[/eluser]
Change your database fields type to VARCHAR(16).
It expects to have TINYINT(2) right now, and you try to insert STRING.

PS : Rerewrite your view code with mine Smile
#18

[eluser]hujan[/eluser]
THANKS noslen1 and Rabbel. It works now :lol:..
Thanks for your help :-)




Theme © iAndrew 2016 - Forum software by © MyBB