Home > Software engineering >  How to pass multi List values using <a> tag?
How to pass multi List values using <a> tag?

Time:01-13

enter image description here

=========================Update================

<select multiple id="selectone">
    <option value="red">red</option>  
    <option value="black">black</option>
    <option value="white">white</option>  
    <option value="yellow">yellow</option>  
     
</select>

<button onclick="MySelect()">Select color</button>



<a asp-page="index" asp-route-SearchString="Test" id="color">Test</a>



<script>
   
    

    function MySelect(){
        var result = document.getElementById("selectone").selectedOptions;
        var arr=[];
        for(let i=0,len = result.length;i<len;i  ){
            if(result[i].selected){
                arr.push("colors[" i "]="   result[i].value)
            }
            
        }


        var str=arr.join("&");
       var a = document.getElementById("color").getAttribute('href');

       var url = a  "&"   str;

       document.getElementById("color").href = url;
       
        
    }


   
</script>

Demo:

enter image description here

  • Related