Change text box value on select box changes

Confluence User - 21 Nov, 2021

Hello everybody,

I'll try to make a long story short, as I've been dealing with this problem for quite a long time now.

I have a form, made of a text box (id), a datepicker, two select box and two radio button.

What I am trying to achieve is to have the textbox (id) populated with the concatenation of the two values selected from the select box (with no luck).

The code (custom HTML) that gave me the best results, so far, is the following:

<script type='text/javascript'>
    $(function(){
        $(document).on('change', 'input', function() {
	// Get the values from the two select box
            var fieldValue = FormUtil.getValue('sub_season_id') + "-" + FormUtil.getValue('sub_associate_id');
            //alert(fieldValue);
	// Set the textbox
            $('#sub_searchID').val(fieldValue);
        });
    });
</script>

The problem is that the event 'change' is fired only if one of the radio buttons get changed, and not when one of the select box gets changed (and it is fired only once!).

Also, I'd perform the same concatenation of the select box values as soon as the page gets loaded, as the values for the two select box could be provided through parameters, but I haven't been able to achieve this result neither using the event 'load', nor the event 'ready'.

Last but not least, I'm using the community edition. 

Any help would be highly appreciated. 

selectbox;forms;events;javascript

3


21 Nov, 2021
confluenceUser
1
confluenceUser

Change

$(document).on('change', 'input', function() {

to

$(document).on('change', 'input, select', function() {
21 Nov, 2021
confluenceUser
confluenceUser

Thank you very much for your reply, Bastiana.

The event now gets fired at every change of one of the two select boxes. 

I still have no clue on how to make it happen also once the page is fully loaded, but this is already a huge step up. Thanks again.

07 Jul, 2022
confluenceUser
confluenceUser

I've tried and it's work. Thank you.

RELATED QUESTIONS

Your answer


To answer a question you'll need an account.

Print