Click here to Skip to main content
15,886,689 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
JavaScript
<script>
    $(document).ready(function () {
        var pad = '0000';

        $("#ProjectCode").change(function () {
            if ($("#ProjectCode").val() != "") {

             
                var id = "My Idea Portal";
                var output = id.split(' ');
                var list = [];
                var currentdate = new Date();
                //var a = id.replace(/\(/g, '').replace(/\)/g, '');
                for (var i = 0; i <= output.length; i++) {
                 
                    var item = output[i].substring(0,1);
                  
                    list.push(item);
                   
                }
                alert(list);
                var Code = currentdate.getFullYear() + "/" + + "." + "/" + (currentdate.getMonth() + 1) + "/" + currentdate.getDate() + "/" + (pad + '@(m + 1)');

                $(".modulecode").val(Code);
            }
            else {

                $(".modulecode").val(null);
            }
        });
    });
</script>


What I have tried:

Here Jquery for the Generate Dropdown Change event in using this Text Generate Code.Now I want To Code for My Idea Portal is "year/M.I.P/month/date/row"
Posted
Updated 17-May-16 18:01pm
Comments
George Jonsson 17-May-16 23:17pm    
Not easy to understand what you mean.
Can you elaborate a bit?
And do use the Improve Question button.
AnantPithadiya 17-May-16 23:37pm    
string "My Idea Portal".this string to split by space and get First character of all split words.

1 solution

Here is your issue :

JavaScript
for (var i = 0; i < output.length; i++) { //here instead of <= it should be < only.
                 
                    var item = output[i].substring(0,1);
                  
                    list.push(item);
                   
                }


[Edit]
Try below code :
JavaScript
var concateVal = "";
                  for (var i = 0; i < output.length; i++) {

                      var item = output[i].substring(0, 1);
                      if (concateVal == "")
                          concateVal = item;
                      else
                          concateVal = concateVal + "." + item;

                  }

                  var Code = currentdate.getFullYear() + "/" + concateVal + "/" + (currentdate.getMonth() + 1) + "/" + currentdate.getDate() + "/" + (pad + '@(m + 1)');


Good luck.
 
Share this answer
 
v2
Comments
AnantPithadiya 18-May-16 0:04am    
I know issue bt how to solve
Raje_ 18-May-16 0:13am    
try the edited solution.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900