• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
default 0

#1
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
(12-13-2016, 04: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
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 the CodeIgniter Community in 2009.          ( Skype: insitfx )
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
1 Guest(s)


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2017 MyBB Group.