Tags Input fetches only one value

2 replies · opened Jun 25, 2022

VvipintkJun 25, 2022

Hi Guys, I'm using Tags input. However the result is only showing one item. Please check the screenshot. Added the code below. CSS and JS added properly.

<section id="content">
<div class="content-wrap">
<div class="card ">
<div class="card-header"><b>Journal View</b></div>
<div class="card-body">
<div class="bottommargin-sm">

            &lt;label for=""&gt;Tagging Support&lt;/label&gt;
            &lt;select class="select-tags form-control select2-hidden-accessible"  id="taginp" multiple="" tabindex="-1" aria-hidden="true" style="width:100%;"&gt;
                
            &lt;/select&gt;

            
            [Test](#)
            
        &lt;/div&gt;
        &lt;/div&gt;
    &lt;/div&gt;
&lt;/div&gt;

<script>
$(document).ready(function(){
$(".select-tags").select2({
tags: true
});

    $(".btnTest").click(function(){
        $inp = document.getElementById('taginp');
        alert($inp.value);
    });
})

</script>

SSemicolon WebSTAFFJun 25, 2022

Hello,

It doesn't work like that in JS as it does in PHP $_POST. You will need to manually retrieve the Values. Consider trying the following code:

$(".select-tags").on( 'change', function() {
	console.log( $(".select-tags").val() );
});

This will definitely work fine. Hope this Helps!

Let us know if we can help you with anything else or if you find any further issues.

VvipintkJun 25, 2022

Thanks. It works for me.

Have the same question, or something new?

Sign in to the Canvas dashboard to reply or open your own topic. Canvas owners get direct help from the SemiColonWeb team.

Reply on the dashboard