how to get checkbox value in chronoform

thirupathy 27 Feb, 2009
hi all,

Am new for joomla. i want to get checkbox value from the chronoform.I tried to get checkbox value. but till not get.
function get_check_value()
{
var c_value = "";
for (var i=0; i < document.orderform.music.length; i++)
   {
   if (document.orderform.music[i].checked)
      {
      c_value = c_value + document.orderform.music[i].value + "\n";
      }
   }
}
this is my java script code to get checkbox value.

the orderform is the name of chronoform. can anyone help me..

thanks in advance..

regards,
THIRUAPTHY.M
GreyHead 27 Feb, 2009
Hi thirupathy,

Please post the Form HTML for the checkboxes so I can see both together.

Bob
thirupathy 27 Feb, 2009
thanks for your reply admin...

this is my html code...
What kind/s of music do you listen to?<br>
<input type="checkbox" name="edit" value="edit"">
Rock<br>
<input type="checkbox" name="music" id="music" value="Reggae">
Reggae<br>
<input type="checkbox" name="music" id="music" value="Pop">
Pop<br>
<input type="checkbox" name="music" id="music" value="Rap">
Rap<br>
<input type="checkbox" name="music" id="music" value="Metal">
Metal<br>
<input type="submit" onclick="get_check_value()">


thanks in advance..

regards,

THIRUPATHY.M
thirupathy 27 Feb, 2009
those code working in localhost. but in joomla only won't get the checkbox value...


regards,

THIRUPATHY.M
thirupathy 27 Feb, 2009
problem solved.

while calling chronoform checkbox we need to add form name with following..


ChronoContact_formname.checkboxname.checked...


thanks chronoform forums support team.


regards,

THIRUPATHY.M
GreyHead 27 Feb, 2009
Hi thirupathy,

All of the checkboxes have the same id (ids should be unique) so your JavaScript will have problems identifying them. I don't believe that it will automatically create an array from these results. Try this:
What kind/s of music do you listen to?<br>
<input type="checkbox" name="edit" value="edit"">
<div id='music_types'>
Rock<br>
<input type="checkbox" name="music" id="music0" value="Reggae">
Reggae<br>
<input type="checkbox" name="music" id="music1" value="Pop">
Pop<br>
<input type="checkbox" name="music" id="music2" value="Rap">
Rap<br>
<input type="checkbox" name="music" id="music3" value="Metal">
Metal<br>
</div>
<input type="submit" onclick="get_check_value()">

function get_check_value()
{
var c_value = "";
var inputs = $('music_types').getElements('input');
for (var i=0; i < inputs.length; i++)
   {
   if (inputs[i].checked)
      {
      c_value += inputs[i].value + "\n";
      }
   }
}
Not tested and may need debugging (NB uses MooTools syntax).

Bob
clovismmbr 25 Oct, 2009
I am confused
What is the real code?
I am trying to get only checked values, but it comes with unchecked values too

Please post a single code that get only checked values
GreyHead 25 Oct, 2009
Hi clovismmbr,

What do you need exactly?? This thread was about getting values with JavaScript I think.

If you just need values submitted then the 'normal' code from the Wizard works OK.

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