Welcome Guest, Not a member yet? Register   Sign In
checkbox always checked
#1

[eluser]ibnclaudius[/eluser]
input:
Quote:<input id="input-remember" type="checkbox" checked="checked" name="remember" value="TRUE" />

controller:
Code:
$remember = $this->input->post('remember');

checking...
Code:
if ($remember === 'TRUE') {}

But the condition is always running.
#2

[eluser]Jan_1[/eluser]
yes as long as you write
Code:
checked=“checked” name=“remember” value=“TRUE”
.
Maybe use a variable there?

See http://ellislab.com/codeigniter/user-gui...elper.html
#3

[eluser]ibnclaudius[/eluser]
Is the same thing...

Code:
$data = array(
    'name'        => 'newsletter',
    'id'          => 'newsletter',
    'value'       => 'accept',
    'checked'     => TRUE,
    'style'       => 'margin:10px',
    );

echo form_checkbox($data);

// Would produce:

<input type="checkbox" name="newsletter" id="newsletter" value="accept" checked="checked" />

#4

[eluser]Jan_1[/eluser]
You are still not using a variable.
Have a look in form_helper for set_value().
#5

[eluser]ibnclaudius[/eluser]
I tried this:
Code:
<input id="input-remember" type="checkbox" checked="checked" name="remember" value="<?php echo set_value('remember', 'TRUE'); ?>" />

But after this line, nothing more is load.
#6

[eluser]ibnclaudius[/eluser]
set_value is wrong, but also with this:

Code:
<input id="input-remember" type="checkbox" checked="checked" name="remember" value="TRUE" <?php echo set_checkbox('remember', 'TRUE'); ?> />

Everything after this line dont load...
#7

[eluser]Jan_1[/eluser]
I think I missunderstood you and don't know your question!?
Back to your first post: Maybe print out $this->input->post('remember');
#8

[eluser]ibnclaudius[/eluser]
I got the problem.

It was in the javascript. I was getting the .val() of the checkbox, that's why the condition was always true, now I'm using .is(':checked')

Thanks ,all!




Theme © iAndrew 2016 - Forum software by © MyBB