JavaScript Remove Item From Comma Separated string

Today, We want to share with you JavaScript Remove Item From Comma Separated string.
In this post we will show you javascript split string by comma, hear for remove duplicates from comma separated string in javascript we will give you demo and example for implement.
In this post, we will learn about remove value from comma separated string javascript with an example.

JavaScript Remove Item From Comma Separated string

There are the Following The simple About JavaScript Remove Item From Comma Separated string Full Information With Example and source code.

As I will cover this Post with live Working example to develop , so the some major files and Directory structures for this example is following below.

  • index.html
Also Read :  Angularjs Multiple Controllers in single page

Remove empty values and duplicates from a comma separated string in JavaScript

Remove Item From Comma Separated string

index.html

This is where I will make a simple HTML form and PHP server side source code for our web application. To make the forms simply all souce code copy and write it into your any text editor Like Notepad++, then save file it as index.html.We learn To Remove specific part of string from comma separated string using JavaScript

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Remove specific part of string from comma separated string using JavaScript</title>
    <script type="text/javascript">
        function RemoveValue() {
            var number = document.getElementById("inpNum").value;
            var str = document.getElementById("studentNumber").innerHTML;
            var studentNumber = str.split(',');
            for (var i = 0; i < studentNumber.length; i++) {
                if (studentNumber[i] === number) {
                    studentNumber.splice(i, 1);
                }
            }
            document.getElementById("studentNumber").innerHTML = studentNumber;
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        Array <span id="studentNumber">1001,1002,1003,1005,1006,1007,1008,1009</span>
        <hr />
        Enter the number to be removed
        <input type="text" id="inpNum" name="name" value="" />
        <br />
        <input type="button" name="name" onclick="RemoveValue();" value="Remove" />
    </div>
    </form>
</body>
</html>

JavaScript Array Remove

remove value from comma separated values string

function spliceValueParam(list, value) {
  return list.replace(new RegExp(",?" + value + ",?"), function(match) {
      var begin_comma = match.charAt(0) === ',',
          last_comma;

      if (begin_comma &&
          (last_comma = match.charAt(match.length - 1) === ',')) {
        return ',';
      }
      return '';
    });
};


alert(spliceValueParam('1,2,3', '1')); // 2,3
alert(spliceValueParam('1,2,3', '2')); // 1,3
alert(spliceValueParam('1,2,3', '3')); // 1,2

Angular 6 CRUD Operations Application Tutorials
JavaScript Remove Item From Comma Separated
JavaScript Remove Item From Comma Separated

Read :

Also Read :  jQuery Ajax QR Code Generator PHP script Download

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about remove duplicates from comma separated string in javascript.
I would like to have feedback on my Pakainfo.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Recommended For You.

How to Open URL in New Tab using ASP.NET Today, We want to share with you How to Open URL in