Click here to Skip to main content
15,917,795 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Using "Serialize" I am collecting all the inputs from a form(where all the text-box are dynamic).
I get the following details:

1.OrderNumber=123412&1.Item=&1.Project=&1.Seiban=&1.OrderStatus=0

My issue is I have to omit all the "1." which are prefixed with the variable name.
I am able to do that but it also affects the other values.
Like after omitting, the details are as follows:

OrderNumber=3412&Item=&Project=&Seiban=&OrderStatus=0

My codes are below.. Please HELP!!

What I have tried:

var reg = new RegExp('\\b' + $htmlFeildValue.split('_')[0] + '.', 'g');

var saveFilterContentsData=appendInstanceIdToUrl($('#'+$htmlFeildValue+'prefilterform').serialize().replace(reg, '')
Posted
Updated 8-Sep-16 2:25am
Comments
Member 11579819 7-Sep-16 8:23am    
My code is working if the value is "61234"..
However, if the value is "1234" then it omits "12"..
ZurdoDev 7-Sep-16 11:39am    
How is 1. getting there?

1 solution

HTML
<!DOCTYPE html>
<html>
<body>

<p>Click the button to replace "Microsoft" with "W3Schools" in the paragraph below:</p>

<p id="demo">Your Answer</p>

<button onclick="myFunction()">Try it</button>

<script>
function myFunction() {
    var resout="1.OrderNumber=123412&1.Item=&1.Project=&1.Seiban=&1.OrderStatus=0"
   
   
    var res = resout.split("1.");
    alert(res);
    document.getElementById("demo").innerHTML = res;
}
</script>

</body>
</html>



copy paste above code in html file and check possibly it helps . it convert your string to string array which shown separated by comma and you can access it by index also
as alert(res[0]); gives you "OrderNumber=123412&" string.
 
Share this answer
 

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