Forums

Earlier versions? and AutoGenerated code question

Bullfn33 23 Jul, 2009
Hi,

Thanks for making this extension, it has helped the operation of my site immensely. However, I downloaded and used Chronoforms a year ago but since then I have started a new Joomla site so I decided to back up my forms from the old site and had planned on uploading them with the latest CF release. Well, I just downloaded the latest version of CF today and noticed A LOT has been changed/added/upgraded since then. So when I went to restore my forms I got all kinds of errors because the fields don't match up anymore. So I tried to make a new form from scratch but couldn't remember what code goes where and what setting I had previously so my validation is not working.(I had most of the code written for me). My question is, can I download an earlier version of CF so that I can install it and see where my codes were inserted and what settings I had previously so that I can match them up in the new form creation fields?

Another thing I noticed in this new version is that I cannot edit and save the AutoGenerated code. Since my forms were/are a little unorthodox in their presented order I had to go in and change it so that the fields were recorded in the correct order. For instance, each question in my form has two radio buttons, one on each side of a small text box. Well, I need the number in the text box to record first then the radio option. Since the first of the two radio options displays before the text box the AutoGenerated code records the selection first. Last year, I was able to edit this order so when I downloaded the results in excel they matched up with my excel documents. It would take way too much time to switch the columns around every week so is there a way to correct the recorded order?

Thanks again
GreyHead 23 Jul, 2009
Bullfn33,

Indeed a lot has changed in the last year. It should be possible to restore from v3.0 but not earlier (I think). You can do it fairly easily with cut and paste but you do need to know what you are doing with the finer details. The main code blocks are still on the Form HTML tab and the Validation tab has not changed much since it was first introduced.

You can get an older version by asking Max using the Contact Us link above.

The Autogenerated Code is no longer editable - and no longer contains a list of fields. Instead it works by matching field names with column names. To change the output sequence for Excel export I think you will eitehr need to change the column sequence in the database table, or to add some custom code for the Export.

Bob
Bullfn33 23 Jul, 2009
Thanks for your reply.

I decided to reproduce the forms on the new version of CF which won't take too long if I can get one of them done. A problem I'm running into is trying to get a second javascript code to run which validates that each group of radio buttons has a selection. The code is useful because the number of radio groups changes from week to week and runs the check regardless of how many groups there are. Where do I put it to get to work? I see the extra code boxes but can't get it to run in there despite adding task=extra to the form URL..gives me

There is no form with this name or may be the form is unpublished, Please check the form and the url and the form management



code I'm trying to add
var theform = window.document.THE_FORM_NAME;
var radioSelected = false;

for (i = 0;  i < theform.fieldname.length;  i++)
{
	if (theform.fieldname[i].checked)
	radioSelected = true;
}
if (!radioSelected)
{
	alert("ERROR:\r\nPlease select the proper fieldname.");
	//theform.fieldname.focus();
	return (false);
}


code I already have in the Form JavaScript code box
/*<![CDATA[*/

function CngNu(ip){
 var frm=ip.form;
 if (!frm.nuary){
  var eles=frm.elements;
  frm.nuary=[];
  for (var zxccnt=1,zxc0=0;zxc0<eles.length;zxc0++){
   if (eles[zxc0].className&&eles[zxc0].className==ip.className){
    frm.nuary.push([eles[zxc0],zxccnt++]);
   }
  }
 }
 for (var cng,zxc1=0;zxc1<frm.nuary.length;zxc1++){
  frm.nuary[zxc1][0].value=frm.nuary[zxc1][0].value.replace(/\D/,'');
  if (frm.nuary[zxc1][0].value==''||frm.nuary[zxc1][0].value<1||frm.nuary[zxc1][0].value>frm.nuary.length){
   frm.nuary[zxc1][0].value=frm.nuary[zxc1][1]
  }
  if (frm.nuary[zxc1][0]==ip){
   cng=zxc1;
  }
 }
 for (var zxc2=0;zxc2<frm.nuary.length;zxc2++){
  if (frm.nuary[zxc2][0]!=ip&&frm.nuary[zxc2][0].value==ip.value){
   frm.nuary[zxc2][0].value=frm.nuary[cng][1];
   frm.nuary[cng][1]=ip.value;
   frm.nuary[zxc2][1]=frm.nuary[zxc2][0].value;
  }
 }
}


/*]]>*/
GreyHead 23 Jul, 2009
Hi Bullfn33,

To add JavaScript you can either append it to the code that you already have in the JavaScript box (inside the CDATA tags in this case) or I perfer to add it to the Form HTML with a little Joomla wrapper that will load it correctly in the page header.
<?php
$script = "
// add JavaScript here without script or cdata tags
";
$doc =& JFactory::getDocument();
$doc->addScript($script);
?>
Or, if you are sure that MooTools will be loaded you can also add an Onload wrapper
<?php
$script = "
// add JavaScript here without script or cdata tags
";
$script = "window.addEvent('domready', function() { $script });";
$doc =& JFactory::getDocument();
$doc->addScript($script);
?>
This has the effect of delaying the execution of the script until the DOM Load is complete (i.e. the core HTML is loaded and can be accessed by the script).

Bob
Bullfn33 24 Jul, 2009
I'm not having any luck getting my radio validation to work. It worked great last year on the older version. I've tried to put it after my first script in the JS text box and it doesn't validate. I've tried to put it in the html text box inside your php tags and I've tried to put it into the extra code box and both times I get either a blank page or an error.

The code I'm trying to insert is actually the following and not what I posted above.
<!-- Begin
function checkForm(form) {
 var el = form.elements;
 for(var i = 0 ; i < el.length ; ++i) {
  if(el[i].type == "radio") {
   var radiogroup = el[el[i].name]; // get the whole set of radio buttons.
   var itemchecked = false;
   for(var j = 0 ; j < radiogroup.length ; ++j) {
    if(radiogroup[j].checked) {
	 itemchecked = true;
	 break;
	}
   }
   if(!itemchecked) { 
    alert("Please choose an answer for "+el[i].name+".");
    if(el[i].focus)
     el[i].focus();
	return false;
   }
  }
 }
 return true;
} 
//  End -->


with this in the form tag attachment
onSubmit="return checkForm(this)
GreyHead 25 Jul, 2009
Hi bullfn33,

This should be OK in the JavaScript box - though I'm not certain about the HTML comments inside <script> tags.

You are missing the final quote in the Onsubmit snippet but that could just be a pasting error.

The ChronoForms validate-one-required should do the same thing.

Bob
Bullfn33 25 Jul, 2009
Bob,

I think you caught my stupid error. There was a pasting error with the Onsubmit code quote and I must have used the same copy on my form..now it works fine. My apologies😶

Now it looks like I won't need an earlier version either. Thanks for your help!
This topic is locked and no more replies can be posted.