Forums

Checkbox Issue :(

jmauver 17 Mar, 2009
Hello all,

My form is working properly apart from this checkbox that has a strange behaviour. Well, on the form I want the user to select all checkbox that applies to his/her case. Only the first checkbox is saving the field on the dabatabase. If I select all, again, only the first one is trigged on the database. I would like the user to select mutiple choices and save them on the database. Below the code generated by the forms wizard:

<label class="cf_label">Facilidades</label><div class="float_left"><input value="Piscina" class="radio" id="Piscina" name="Piscina" type="checkbox"><label for="Piscina" class="check_label">Piscina</label><br><input value=" Sauna" class="radio" id="_Sauna" name="_Sauna" type="checkbox"><label for="_Sauna" class="check_label"> Sauna</label><br><input value=" Bar" class="radio" id="_Bar" name="_Bar" type="checkbox"><label for="_Bar" class="check_label"> Bar</label><br><input value=" Restaurante" class="radio" id="_Restaurante" name="_Restaurante" type="checkbox"><label for="_Restaurante" class="check_label"> Restaurante</label><br><input value=" Estacionamento" class="radio" id="_Estacionamento" name="_Estacionamento" type="checkbox"><label for="_Estacionamento" class="check_label"> Estacionamento</label><br><input value=" Ar_condicionado" class="radio" id="_Ar_condicionado" name="_Ar_condicionado" type="checkbox"><label for="_Ar_condicionado" class="check_label"> Ar_Condicionado</label><br><input value=" Internet" class="radio" id="_Internet" name="_Internet" type="checkbox"><label for="_Internet" class="check_label"> Internet</label><br></div><a onclick="return false;" class="tooltiplink"><img  class=tooltipimg height=16 src="components/com_chronocontact/css/images/tooltip.png" width=16 border=0></a><div  class="tooltipdiv">Facilidades :: Selecione as facilidades que o hotel oferece</div>
<div></div>


Any help is greatly appreaciated.

Thanks

Jmauver
GreyHead 17 Mar, 2009
Hi jamuver,

All except the first have names that start with an underscore name="_Sauna" - this is technically illegal html (names can only start with an alpha character) and is probably what is causing the problem. I think these arise because you have spaces before the names in the Wizard.

Bob
jmauver 17 Mar, 2009
Thanks Bob.

Ok, I will rename all the fields name and remove underscore. So, I am not sure, should I rename the MYSQL database fields too as they start with underscore ? For example, I have a field named "_sauna", among others. Or just renaming the HTML code is enough ? Thanks again for your prompt response.

Regards,

Jmauver
GreyHead 17 Mar, 2009
Hi Jmauver,

They need to match (and I suspect that MySQL won't be happy with the underscores either). If you don't have any critical data saved it might be quicker to drop the database table and create a new one using the icon in the Forms Manager.

While you are making changes it might be useful to give all the block of check boxes an array name like name='feauture[]' that way you'll collect all the results in one field. Usually that's easier to handle but it depends on your application.

Bob
jmauver 17 Mar, 2009
Thanks a lot Bob. I will re-create the table as suggested. I do not have any critical data yet.

Nice support from you.

Jmauver
This topic is locked and no more replies can be posted.