× Form Help

Copy Element Label to another Element while typing

  • LNorth
  • Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 6
  • Thank you received: 0

LNorth created the topic: Copy Element Label to another Element while typing

I have used
setInterval('ff_getElementByName("TARGETFIELD").value=ff_getElementByName("ORIGINALFIELD").value',500);
to copy an element value selected from list but I want to copy the label, the second element of the definition, i.e. the "Title" element [0;Title 1;value1]. I am populating the list definition from a ContentBuilder Data Storage but also want to have both sides of the definition entered from one selection. I have tried substituting "title" and "label" for the "value in ff_getElementByName("ORIGINALFIELD").value but neither work. Is there a way to access the element Title?
#236754
  • Posts: 2428
  • Karma: 85
  • Thank you received: 330

mihaela replied the topic: Copy Element Label to another Element while typing

Hello,

Please use this function to grab the Title (the option's displayed text) :
var tmp = JQuery("[name=\"ff_nm_SELECTLISTNAME[]\"] option:selected").text();
NOTE: In the code above you have to replace SELECTLISTNAME with the name of your select list element.

This way you will have a title of selected option saved in a variable tmp.

Let me know whether this is working as you wanted.

Regards,

Mihaela
#236756
The following user(s) said Thank You: LNorth
  • LNorth
  • Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 6
  • Thank you received: 0

LNorth replied the topic: Copy Element Label to another Element while typing

Hi, thanks for your input.
It worked fine but only as the form loaded, as I wanted it to react to any changes I used the "setInterval" Timing Event as below.

var MyVar = setInterval(ClearRoundEntry, 500);

function ClearRoundEntry()
{
var tmp = JQuery("[name=\"ff_nm_cr_dog_select[]\"] option:selected").text();
ff_getElementByName("dog_name").value=tmp;
}

I also want the same effect from a "Radio Group" selection and added code as below.


var MyVar = setInterval(ClearRoundEntry, 500);

function ClearRoundEntry()
{
var tmp = JQuery("[name=\"ff_nm_cr_dog_select[]\"] option:selected").text();
ff_getElementByName("dog_name").value=tmp;

var tmp1 = JQuery("[name=\"ff_nm_class_type[]\"] option:selected").text();
ff_getElementByName("class_type_name").value=tmp1;
}

ff_nm_class_type is the Radio Group and class_type_name is a textfield as before. Unfortunately this doesn't work and I suspect I need something other than "option:selected" for a Radio Group.

Any suggestions Please?
#236760
  • Posts: 2428
  • Karma: 85
  • Thank you received: 330

mihaela replied the topic: Copy Element Label to another Element while typing

Hello,

Please take a look at the answer I've provided in this ticket regarding the same question crosstec.org/en/forums/1-forums/126451-c...e-typing.html#236764 .

Best regards,

Mihaela
#236832
Moderators: ForumSupporttomeperica
Time to create page: 0.063 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