Welcome Guest, Not a member yet? Register   Sign In
default 0
#3

(This post was last modified: 04-07-2017, 04:49 AM by InsiteFX. Edit Reason: Added NOTE. )

Not sure if this is what your looking for, next time try to explain your problem better
so that we can understand what you are looking for.

You can add this to your controller etc;

PHP Code:
    /**
     * isChecked ()
     * ---------------------------------------------------------------------------
     *
     * $chkBoxName  - The name  of the form checkbox or radiobutton 
     * $chkBoxValue - The value of the form checkbox or radiobutton
     * 
     * EXAMPLE:
     * 
     * $formValue = $this->isChecked('chkBox1', '1');
     * 
     * @param  $chkBoxName  - the input name you set
     * @param  $chkBoxValue - the value that you set 1 0 yes no etc;
     * @return bool
     */
    
function isChecked($chkBoxName$chkBoxValue)
    {
        if ( ! empty(
$this->input->post[$chkBoxName]))
        {
            foreach (
$this->input->post[$chkBoxName] as $chkBoxVal)
            {
                if (
$chkBoxVal == $chkBoxValue)
                {
                    return 
true;
                }
            }
        }

        return 
false;
    } 

NOTE: A checkbox or radiobutton does not return any value when they are unchecked!
You may need to change it to 0 if you get a false returned from this method.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply


Messages In This Thread
default 0 - by twonno - 12-13-2016, 03:40 AM
RE: default 0 - by MuhamedAuda - 04-06-2017, 11:27 PM
RE: default 0 - by InsiteFX - 04-07-2017, 03:39 AM



Theme © iAndrew 2016 - Forum software by © MyBB