Profile page plugin multiple checkboxes repopulation.

jrmobile 13 Jan, 2013
Hi Everyone,
I'm having some difficulties with using Profile Page plugin.

This is the form i've created.
http://winterstardance.ru/index.php?option=com_chronocontact&chronoformname=Registration_RU_Edit&cf_id=378

As you can see all fields are being populated perfectly, except one - check0.
It holds all values for all checkboxes on the form.
For this record check0 holds "Juveniles La, Juveniles St".
It means two checkboxes have to be checked.

I've tried to check it manualy by javascript.

function populate_checkboxes() {

var $str = {check0};
var $price =  $str.split(",");
var $form = document.forms[0];

    for ($counter = 0; $counter < $price.length; $counter++) {
	document.getElementById($price[$counter]).checked = true;}

}


window.addEvent('domready', populate_checkboxes());


Function fires error for {check0} holder.

Would someone give me a hand on this. How do i pass check0 value to the function.

I believe that there is a easier way, rather then getting cf_id from url and executing additional query.

Thanks in advance.
jrmobile 16 Jan, 2013
To All,

Problem resolved.

I've put this call in HTML section
<?php
echo "<script type='text/Javascript'>populate_checkboxes('{check0}');</script>";
?>


And this to the JavaScript

function populate_checkboxes(check0) {

var $str = check0;

var $categories =  $str.split(",");

    for ($counter = 0; $counter < $categories.length+1; $counter++) {
        checkbox = document.getElementById($categories[$counter]);
	checkbox.checked = true;}

}


GreyHead 16 Jan, 2013
Hi jrmobile,

Well found.

Bob

For other readers: this code is for ChronoForms v3 only.
This topic is locked and no more replies can be posted.