Welcome to the nuBuilder Forums!

Register and log in to access exclusive forums and content available only to registered users.

Copy field to another Field after Edit

Questions related to using nuBuilder Forte.
Post Reply
oli
Posts: 118
Joined: Sat Mar 20, 2021 3:22 pm
Has thanked: 4 times

Copy field to another Field after Edit

Unread post by oli »

Hi All,

what is the best way to copy the value of a textarea field (textarea1) to another textarea field (textarea2) on the same form after textarea1 was changed?

Is there any simple solution available?

Thanks in advance and best regards,
Oli
kev1n
nuBuilder Team
Posts: 4305
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 445 times
Contact:

Re: Copy field to another Field after Edit

Unread post by kev1n »

Hi Oli,

Add a Custom Event onchange to your first Textarea object and call:

Code: Select all

$('#other_text_area_id').val($(this).val()).change();
You do not have the required permissions to view the files attached to this post.
oli
Posts: 118
Joined: Sat Mar 20, 2021 3:22 pm
Has thanked: 4 times

Re: Copy field to another Field after Edit

Unread post by oli »

Thanks a lot!
oli
Posts: 118
Joined: Sat Mar 20, 2021 3:22 pm
Has thanked: 4 times

Re: Copy field to another Field after Edit

Unread post by oli »

Additionally I tried to set a button to hidden if a specific value of a select field was choosen.
This is was I added to the select object and if the value is "in Planung" the Button should not be visible anymore.
But I guess I still have some errors in the code and I couldn't find an example how to get the value for a specific SELECT object and use it in an IF statement.
screenshot.jpg
BR and thanks in advance, Oli
You do not have the required permissions to view the files attached to this post.
kev1n
nuBuilder Team
Posts: 4305
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 445 times
Contact:

Re: Copy field to another Field after Edit

Unread post by kev1n »

Try this:

Code: Select all

function stringsAreEqual(a, b) {
	var a = escape(a).replace(/%20/g, '').replace(/%A0/g, '');
	var b = escape(b).replace(/%20/g, '').replace(/%A0/g, '');
	return a == b;
}

nuShow('run_angebot_print',  ! stringsAreEqual(this.value, 'in Planung') );
If the text and values are different, you need to retrieve the text like this:

Code: Select all

$("#your_select_id option:selected").text();
oli
Posts: 118
Joined: Sat Mar 20, 2021 3:22 pm
Has thanked: 4 times

Re: Copy field to another Field after Edit

Unread post by oli »

it works :-)
Thank you!
oli
Posts: 118
Joined: Sat Mar 20, 2021 3:22 pm
Has thanked: 4 times

Re: Copy field to another Field after Edit

Unread post by oli »

Since I have to check various status values and the button should be hidden after the form was accessed it would be easier to hide the button with PHP.
Is there a way to conditionally hide or show objects with PHP as well?
kev1n
nuBuilder Team
Posts: 4305
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 445 times
Contact:

Re: Copy field to another Field after Edit

Unread post by kev1n »

You will have to use JavaScript. But you could prepare it in BE and run in with nuAddJavascript
Post Reply