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

(This post was last modified: 04-07-2017, 02:07 AM by ciadmin.)

hello guys
[redacted]non-English[/redacted], please help me
how to create a function if there is an empty form then automatically charged a value of 0 in the table using CodeIgniter

thanks
Reply
#2

(This post was last modified: 04-07-2017, 02:07 AM by ciadmin.)

(12-13-2016, 03:40 AM)twonno Wrote: hello guys
..., please help me
how to create a function if there is an empty form then automatically charged a value of 0 in the table using CodeIgniter

thanks

Hello, Can you please explain more of what you need it ? like example ..etc
Did you started a code ?
Reply
#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




Theme © iAndrew 2016 - Forum software by © MyBB