Support Forum

Every time that you post a problem, PLEASE add the Joomla and the extension's versions and revisions (for example: Joomla 3.3.6, Contact Enhanced 3.3.5), PHP version and Server's Operating System. If you only manage only one site it is easier if you edit your profile and just add that information to your signature. Don't forget to add a detailed description of the problem. If possible, write down all steps to simulate the problem.

Before submitting a new post, PLEASE make sure you are running the latest version, test in different browsers (IE, FF, Chrome,..) and clear Joomla and browser's cache after every change you make.

Also, most questions are already answered in our FAQ and in iFAQ and Contact Enhanced documentation pages.

Can't set fields as Required/not req. via Attribute field

10 years 10 months ago - 10 years 10 months ago #14533 by beam
Hi Douglas,

I'm trying to get some conditional code working when a Yes|No radiobox is selected by the user.

I want it to diplay/hide 2 hiden field by default when clicking Yes, that works fine using code found on your site.

The issue I have is getting those same 2 fields to switch from Not required to Required, and that, after trying different approaches & syntax I'm unable to get to work.

Here are the custom fields and code I'm working on:

Radiobox field where the Yes|No selection occurs:
ID = 64

Checkbox = that needs to be visible when radiobox selected with Yes , this works with code below. But forcing it to REquired from Non required (default value) does not work.
ID = 58

Text field = that needs to be visible when radiobox selected with Yes , this works with code below. But forcing it to Required from Non required (default value) does not work.
ID = 63

Here is the code in Attribute field of custom field ID = 64 (radio box above). The syntax I used below in code, used to work with CE v.1.5.11.3 with Joomla 1.5.26. My code below is for/needs to work for a site with Joomla 2.5.11 and CE v.2.5.14

onclick="value = this.getProperty('value');
if(value=='Yes'){
$('ce-cf-container-63').setStyle('display','block');
$('ce-cf-container-58').setStyle('display','block');

$('cf_63').addClass('required')
$('cf_58').addClass('required')


} else {

$('ce-cf-container-63').setStyle('display','none');
$('ce-cf-container-58').setStyle('display','none');


$('cf_63').removeClass('required')
$('cf_58').removeClass('required')

}"


Thank you for your great support

Best Regards,

Marc


EDIT: Put this post in wrong category , sorry should of been Component CE not Plugin... submitted to fast. thanks.

Please Log in or Create an account to join the conversation.

10 years 10 months ago #14534 by beam
Note: I also tried:

$('ce-cf-container-63').removeClass('required') and on addClass as well for both fields, must have the wrong syntax / approach here, if it's array based, not sure how to factor it in this conditional code.

Thanks

Marc

Please Log in or Create an account to join the conversation.

10 years 10 months ago #14535 by douglas
Dear Marc,

Contact Enhanced has changed since Joomla 1.5. MooTools in Joomla core has been upgraded to the latest version and now the field's name and id attributes are no longer cf_ID, it is the field Alias. Therefore the javascript code is a bit different. Please read the online documentation here:
idealextensions.com/joomla-ext...d-on-a-radiobox-selection.html

You can try this:
field = document.id('ALIAS_HERE');
field.removeClass('required');


Best regards,

Please Log in or Create an account to join the conversation.

10 years 10 months ago #14544 by beam
Hi Douglas,

I've tried the cod below, the only thing not working is field for which alias = q11_sub_q2 (it's a checkbox) that is not set to Required/Not Required. Although with same syntax, for field with alias q11_sub_q1, a text field, it works its set as required when selecting Yes for radiobox.

What should be the code for it to work on line with field alias: q11_sub_q2 ?

Code in radiobox 's attribute field:

onclick="value = this.getProperty('value');
if(value=='Yes'){
$('ce-cf-container-63').setStyle('display','block');
$('ce-cf-container-58').setStyle('display','block');

field = document.id('q11_sub_q1');
field.addClass('required');

field = document.id('q11_sub_q2');
field.addClass('required');

} else {

$('ce-cf-container-63').setStyle('display','none');
$('ce-cf-container-58').setStyle('display','none');

field = document.id('q11_sub_q1');
field.removeClass('required');

field = document.id('q11_sub_q2');
field.removeClass('required');

}"

Thank you

Marc

Please Log in or Create an account to join the conversation.

10 years 10 months ago #14545 by douglas
Dear Marc,

The checkbox is a bit different, because they are actually a bunch of fields instead of one, so you will add this class to the last field:
validate-boxes

The field ID will be your alias_(number of fields - 1). So let's say that you have 6 checkbox options, then your last field will be alias_5. In your case it would be q11_sub_q2_5.

So the javascript for that part would be:
field = document.id('q11_sub_q2_5');
field.addClass('validate-boxes');


Best regards,

Please Log in or Create an account to join the conversation.

10 years 10 months ago #14546 by beam
Thanks Douglas,

It works fine now!!

Best Regards,

Marc

Please Log in or Create an account to join the conversation.

Powered by Kunena Forum

Copyright © 2018 IdealExtensions.com. All Rights Reserved.

This site is not affiliated with or endorsed by the Joomla!™ Project. It is not supported or warranted by the Joomla!™ Project or Open Source Matters™. The Joomla!™ logo is used under a limited license granted by Open Source Matters™, the trademark holder in the United States and other countries.
We may collect your IP address and your browser's User Agent string while using our site for security reasons and deriving aggregate information (analytics). This information is retained for a minimum of 1 and a maximum of 24 months.
Feedback