Update Subject input in real time - Customer New Ticket

English! place to talk about development, programming and coding
Post Reply
itx8
Znuny newbie
Posts: 4
Joined: 12 Feb 2016, 12:11
Znuny Version: 4.0.11

Update Subject input in real time - Customer New Ticket

Post by itx8 »

Hi Guys,

I have a problem with run function during onchange event.
I want to put to the Subject input text selected from queues list in Customer New Ticket Form.

I have added onchange="updateSubject()" in LayoutTicket.pm

Code: Select all

# build tree list
    $Param{MoveQueuesStrg} = '<select name="'
        . $Param{Name}
        . '" id="'
        . $Param{Name}
        . '" class="'
        . $Class
		. '"onchange="updateSubject()"'
        . "\ $Size $Multiple $OnChangeSubmit>\n";
and function updateSubject() in CustomerTicketMessage.tt

Code: Select all

[% RenderBlockStart("Queue") %]
                <div>
                    <label for="Dest" class="Mandatory">
                        <span class="Marker">*</span>
                        [% Translate("Category") | html %]:
                    </label>
                    [% Data.ToStrg %]
                    <div id="DestError" class="TooltipErrorMessage" ><p>[% Translate("This field is required.") | html %]</p></div>
                    <div id="DestServerError" class="TooltipErrorMessage NoJavaScriptMessage[% Data.QueueInvalid | html %]" ><p>[% Translate("This field is required.") | html %]</p></div>
                    <div class="Clear"></div>
                </div>

	
[% WRAPPER JSOnDocumentComplete %]
<script type="text/javascript">//<![CDATA[
    $('#Dest').bind('change', function (Event) {
        Core.AJAX.FormUpdate($('#NewCustomerTicket'), 'AJAXUpdate', 'Dest', ['TypeID', 'PriorityID', 'ServiceID', 'SLAID', [% Data.DynamicFieldNamesStrg %]]);
    });
//]]>


function updateSubject(){
var s = document.getElementById('Dest');
var strS = s.options[s.selectedIndex].text;
document.getElementById('Subject').value = strS;
}

</script>
[% END %]

But when I select any queue from the list the text are not showing in Subject input. I will be grateful for your help
reneeb
Znuny guru
Posts: 5018
Joined: 13 Mar 2011, 09:54
Znuny Version: 6.0.x
Real Name: Renée Bäcker
Company: Perl-Services.de
Contact:

Re: Update Subject input in real time - Customer New Ticket

Post by reneeb »

Check what is in

Code: Select all

$OnChangeSubmit
You probably should add your function call there
Perl / Znuny development: http://perl-services.de
Free Znuny add ons from the community: http://opar.perl-services.de
Commercial add ons: http://feature-addons.de
itx8
Znuny newbie
Posts: 4
Joined: 12 Feb 2016, 12:11
Znuny Version: 4.0.11

Re: Update Subject input in real time - Customer New Ticket

Post by itx8 »

I don't know exactly where I should put my function

Code: Select all

sub AgentQueueListOption {
    my ( $Self, %Param ) = @_;

    my $Size           = $Param{Size}                      ? "size='$Param{Size}'"  : '';
    my $MaxLevel       = defined( $Param{MaxLevel} )       ? $Param{MaxLevel}       : 10;
    my $SelectedID     = defined( $Param{SelectedID} )     ? $Param{SelectedID}     : '';
    my $Selected       = defined( $Param{Selected} )       ? $Param{Selected}       : '';
    my $CurrentQueueID = defined( $Param{CurrentQueueID} ) ? $Param{CurrentQueueID} : '';
    my $Class          = defined( $Param{Class} )          ? $Param{Class}          : '';
    my $SelectedIDRefArray = $Param{SelectedIDRefArray} || '';
    my $Multiple       = $Param{Multiple}                  ? 'multiple = "multiple"' : '';
    my $TreeView       = $Param{TreeView}                  ? $Param{TreeView}        : 0;
    my $OptionTitle    = defined( $Param{OptionTitle} )    ? $Param{OptionTitle}     : 0;
    my $OnChangeSubmit = defined( $Param{OnChangeSubmit} ) ? $Param{OnChangeSubmit}  : '';
    if ($OnChangeSubmit) {
        $OnChangeSubmit = " onchange=\"submit();\"";
    }
    else {
        $OnChangeSubmit = '';
    }

    # set OnChange if AJAX is used
    if ( $Param{Ajax} ) {
        if ( !$Param{Ajax}->{Depend} ) {
            $Self->{LogObject}->Log(
                Priority => 'error',
                Message  => 'Need Depend Param Ajax option!',
            );
            $Self->FatalError();
        }
        if ( !$Param{Ajax}->{Update} ) {
            $Self->{LogObject}->Log(
                Priority => 'error',
                Message  => 'Need Update Param Ajax option()!',
            );
            $Self->FatalError();
        }
        $Param{OnChange} = "Core.AJAX.FormUpdate(\$('#"
            . $Param{Name} . "'), '"
            . $Param{Ajax}->{Subaction} . "',"
            . " '$Param{Name}',"
            . " ['"
            . join( "', '", @{ $Param{Ajax}->{Update} } ) . "']);";
    }

    if ( $Param{OnChange} ) {
        $OnChangeSubmit = " onchange=\"$Param{OnChange}\"";
    }
In view page code on the web browser I can see the onchange="updateSubject()" but it not working

Code: Select all

<select name="Dest" id="Dest" class="Validate_Required " onchange="updateSubject()"   >
reneeb
Znuny guru
Posts: 5018
Joined: 13 Mar 2011, 09:54
Znuny Version: 6.0.x
Real Name: Renée Bäcker
Company: Perl-Services.de
Contact:

Re: Update Subject input in real time - Customer New Ticket

Post by reneeb »

You have to add your JavaScript function in the .tt file...
Perl / Znuny development: http://perl-services.de
Free Znuny add ons from the community: http://opar.perl-services.de
Commercial add ons: http://feature-addons.de
itx8
Znuny newbie
Posts: 4
Joined: 12 Feb 2016, 12:11
Znuny Version: 4.0.11

Re: Update Subject input in real time - Customer New Ticket

Post by itx8 »

It was done as I wrote in the first post. My function is in CustomerTicketMessage.tt file.
itx8
Znuny newbie
Posts: 4
Joined: 12 Feb 2016, 12:11
Znuny Version: 4.0.11

Re: Update Subject input in real time - Customer New Ticket

Post by itx8 »

Any help??
Post Reply