Welcome Guest, Not a member yet? Register   Sign In
How to send a zero value in this form particulary case
#1

[eluser]Elias Rufino[/eluser]
Hello guys.

I have some work to do in a project that I didn't write. I have not much experience with CI but I did lots of things they asked me to do. But I have a problem with a form, and here is the problem:

The form ask for user address. It has a "number" to the residence, and nowadays it's working in this way:

views/form
Code:
(...)
         <tr>
          <td colspan="2"><span class="red-text">*</span> Number:<br />
           &lt;input name="numberx" type="text" id="numberx" size="15" value="&lt;?php echo set_value('numberx', @$numberx); ?&gt;" maxlength="6" /&gt;
          </td>
         </tr>

(...)

controllers/form
Code:
(...)
        $this->form_validation->set_rules('numberx', '<strong>Number</strong>', 'required|is_natural_no_zero');
(...)

So, the problem is, they asked me to put an option that the user could set that the address has no number (n/n), so I did the follow:

views/form

Code:
(...)
           &lt;input type="text" name="numberx" id="numberx" size="15" value="&lt;?php echo set_value('numberx', @$numberx); ?&gt;" maxlength="6"/&gt;
&lt;input type="checkbox" name="disablepo" here is a onclick equals to .. disablepo() ..(I can't put it here, don't know why)  /&gt; No number <br />

(...)


In my global.js, I used:

Code:
function disablepo() {
            var x;
            x = document.getElementById("numberx");
            if (x.disabled != true) {
                x.disabled = true;
            }
            else
            {
                x.disabled = false;
            }
    }

It worked. But in the case that user doesn't have a number, I must send a zero value to form, it will be placed in a database. And I really don't know how to send this zero in the form, if the user check "No number" option.

Can someone please give me a light?


Thank you in advance,

Elias Rufino


Messages In This Thread
How to send a zero value in this form particulary case - by El Forum - 08-29-2012, 11:05 AM
How to send a zero value in this form particulary case - by El Forum - 08-29-2012, 12:25 PM
How to send a zero value in this form particulary case - by El Forum - 09-05-2012, 11:14 PM



Theme © iAndrew 2016 - Forum software by © MyBB