[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 />
<input name="numberx" type="text" id="numberx" size="15" value="<?php echo set_value('numberx', @$numberx); ?>" maxlength="6" />
</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:
(...)
<input type="text" name="numberx" id="numberx" size="15" value="<?php echo set_value('numberx', @$numberx); ?>" maxlength="6"/>
<input type="checkbox" name="disablepo" here is a onclick equals to .. disablepo() ..(I can't put it here, don't know why) /> 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