Change fieldset legend programatically

  • baileynp
  • Topic Author
  • Offline
  • Senior Boarder
  • Senior Boarder
  • Posts: 76
  • Thank you received: 1

baileynp created the topic: Change fieldset legend programatically

Hi

I have various fieldsets (sections) in my form. How can I change the legend programatically?

I have the id of the fieldset, but the line I need to change looks like:
<span class="bfLegend-m">Listening</span>

How do I change the text in the span?

Regards
#237576
  • baileynp
  • Topic Author
  • Offline
  • Senior Boarder
  • Senior Boarder
  • Posts: 76
  • Thank you received: 1

baileynp replied the topic: Change fieldset legend programatically

Hi - any ideas?
#237591
  • Posts: 2553
  • Karma: 87
  • Thank you received: 343

mihaela replied the topic: Change fieldset legend programatically

Hello,

Please explain a bit more what you want to achieve because I am not sure that I understand.

Do you mean that you have a section with a text in your form and you wish to change the text in the span with some coding, depending on some other parameter?

If that is the case, depending on what do you wish to change the value?

Regards,

Mihaela
#237595
  • baileynp
  • Topic Author
  • Offline
  • Senior Boarder
  • Senior Boarder
  • Posts: 76
  • Thank you received: 1

baileynp replied the topic: Change fieldset legend programatically

Hi

Attached is an example:



The legends are currently in English, but for users who choose their native language via a drop-down menu, I want to be able to change the legends to reflect the chosen language.

The actual data for the option groups is easy-peasy as that's just an SQL query based on language id for the user, but I'm stuck with how to change the text of the fields legends.

Regards
#237596
Attachments:
  • Posts: 2553
  • Karma: 87
  • Thank you received: 343

mihaela replied the topic: Change fieldset legend programatically

Hello,

I've been looking into this issue and tried to make it work as you wanted since I have backend login info from your last topic.

I've come to the following solution.

Go to the "ff_StudentPlacementBeforePiece" piece that you have written and after this line of code:
$lang_tag = $lang->getTag();
add the following code:
if($lang_tag == "de-DE")
echo '
<script>
 jQuery(document).ready(function(){
	jQuery("#Listening .bfLegend-m").text("Hören");
        jQuery("#Reading .bfLegend-m").text("lesen");
       // add here line of code for each section title
    });    
 </script>
';
else if($lang_tag == "it-IT")
echo '
<script>
 jQuery(document).ready(function(){
	jQuery("#Listening .bfLegend-m").text("Ascoltando");
        jQuery("#Reading .bfLegend-m").text("Lettura");
       // add here line of code for each section title
    });    
 </script>
';
// add here more iff conditions

Let me know whether you have managed to set this for your form and whetehr it is working as you wanted.

Regards,

Mihaela
#237600
  • baileynp
  • Topic Author
  • Offline
  • Senior Boarder
  • Senior Boarder
  • Posts: 76
  • Thank you received: 1

baileynp replied the topic: Change fieldset legend programatically

Hi Mihaela

As you can see, that was exactly what I was looking for. Thank you so much. :)



And I got a free language lesson too. :P

Thank you once again.
#237602
Attachments:
Moderators: ForumSupporttomeperica
Time to create page: 0.297 seconds

New Icon Packs Category!

Crosstec is now offering icon packs.

If you are a paying subscriber, icon packs are automatically added to your account.

Check out our icon packs page!

Live Support Chat Opened!

Join our Discord chat here to receive live support and talk directly to the team!

Summer Sale!

50% discount on all of our extension subscription plans, templates and icon packs!

Get Your Subscription Here

News and Updates

Get informed about new downloads, updates and more in our News and Updates newsletter.

All Extensions Subscription

Get 1 year access to all of our current and future products and 1 year of professional support -- 99 for just 49! (Summer Sale)

No support per domain or website installation limits! Includes all of our current and future Joomla!® extensions, Joomla!® templates for the duration of your membership. This means, by purchasing an All Extensions Subscription you'll have it all covered!

Get it from here

3rd Party Discount - 25% Off

We help you to keep your costs under control. If you are a new member and purchased a form building tool from a different form vendor, then you'll get a 25% discount on our subscription plans.

How to receive the discount:

Send us a quick email to sales@crosstec.org with a proof of purchase (for example a paypal receipt), await payment instructions and enjoy your membership!

Live Support Chat Opened!

Join our Discord chat here to receive live support and talk directly to the team!

Community Reward

Help us to create new extensions and plugins! With only $5 you help us a lot and get unlimited download access to all of our products, professional support and even more. Get your reward now!

Read More Here