value of one field depending on more select-fields

  • Mister.Miracle
  • Topic Author
  • Offline
  • Expert Boarder
  • Expert Boarder
  • Posts: 81
  • Thank you received: 0

Mister.Miracle created the topic: value of one field depending on more select-fields

Hello,

i use a form with a lot of select fields.
Depending on a field-value, selected at the select-field there are shown some other fields, where the user is able to enter some values by hand.

now i would be implement a feature, that the displayed on fields shoud be pre-valued depeneding on the choosen select-field1 and select-field2 or select-field1 and select-field3

the text-field should enter by itself the value, but it has to be changable.

Hope you understand, what i want to do :-)
#237255
  • Posts: 5958
  • Karma: 119
  • Thank you received: 554

MarioPuco replied the topic: value of one field depending on more select-fields

Hi,

This should be very easy to do and here is the example code on how-to :
var val =JQuery('[name="ff_nm_SelectList[]"]').val();  

if (val=="value1"){
ff_getElementByName("TEXT_ELEM1").value="Yes";
}//if
else if (val=="value2"){
ff_getElementByName("TEXT_ELEM2").value="Maybe";
}//else if
else if (val=="value3"){
ff_getElementByName("TEXT_ELEM3").value="No";
}//else if

Based on select list values TEXT_ELEM1,2,3 should be populated with according values.
Hope this helps.

Regards,
Mario

Satisfied with our Support ?
PayPal Tip
===============================================
Need to renew Pro Support?
Buy Here!
===============================================
Satisfied?
Consider a membership!
===============================================
Like us on Facebook
===============================================
#237257
  • Mister.Miracle
  • Topic Author
  • Offline
  • Expert Boarder
  • Expert Boarder
  • Posts: 81
  • Thank you received: 0

Mister.Miracle replied the topic: value of one field depending on more select-fields

thank you for your help.

i will try it, but where should i write this code.... at the text-field-element or a script-part of the form?
#237284
  • Posts: 5958
  • Karma: 119
  • Thank you received: 554

MarioPuco replied the topic: value of one field depending on more select-fields

Hi,

Maybe you can write it inside element action script ?
So you can set this action script to execute on element "Change".

Maybe this article will give you and idea how to achieve what you want : crosstec.org/en/support/online-documenta...ting-textfields.html

Regards,
Mario

Satisfied with our Support ?
PayPal Tip
===============================================
Need to renew Pro Support?
Buy Here!
===============================================
Satisfied?
Consider a membership!
===============================================
Like us on Facebook
===============================================
#237287
  • Mister.Miracle
  • Topic Author
  • Offline
  • Expert Boarder
  • Expert Boarder
  • Posts: 81
  • Thank you received: 0

Mister.Miracle replied the topic: value of one field depending on more select-fields

Hello and thank you for your hint, i will read it again :-)

Now your hint is also to use more than one select-field or text-fields...

the entry of the select-field is this:
0;not choosen;notchoosen
0;Value 1;value1
0;Value 2;value2

the code of the action-script dont work, but i dont know why :-(
function ff_SELECTFIELDLABEL_action(element, action)
{	
	switch (action) {
		case 'change':
			if (ff_getElementByName('SELECTFIELDLABEL').value = "value1")
			{
				ff_getElementByName('TEXTFIELDLABEL').value = "Test";
			}
			}//if
			
			else if (ff_getElementByName('SELECTFIELDLABEL').value = "Value 2"
				{
					ff_getElementByName('TEXTFIELDLABEL').value = "Test 2";
				}
            break;
        default:;
    } // switch
} // ff_SELECTFIELDLABEL_action[code]

i am not able to test the code or find my mistake :-(

The next problem i dont know: is it able to change a hidden status and / or the read-only-status of a field depending on a value?

is this possible to create code-parts like this in this actionscript:
ff_getElementByName("bla").readOnly=true;
ff_getElementByName("bla").hidden=true;

thank you for helping :-)
#237296
  • Mister.Miracle
  • Topic Author
  • Offline
  • Expert Boarder
  • Expert Boarder
  • Posts: 81
  • Thank you received: 0

Mister.Miracle replied the topic: value of one field depending on more select-fields

could someone explain, where i created an error while coding... because it dont work as wanted :-(

Please help me.
#237395
Moderators: ForumSupporttomeperica
Time to create page: 0.072 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