Click here to Skip to main content
15,892,298 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Hi friends ,

How to remove comma from id attribute from input tag'

XML
<input type="radio" name="name@{ @i}" id="roomtype@{@id}" checked="Checked" value="@id" />
                                        <label for="roomtype@{@id}" class="all_label checked" id="l_1_@{ @id}">
                                            &nbsp;</label>


@id is dynamically generated
for example = l_1_1,2,3,4

i want to replace this l_1_1,2,3,4 to l_1_1_2_3_4

this input tag is inside forloop so the next id will be l_1_4,6,7,8

please give me a solution.
is there any way to filter it in jquery

comma is not a valid thing .. but what to do i am blocked now. ... please give me a result to replace comma..


Good answer will be appreciated.
Posted
Comments
Sandip.Nascar 30-Dec-13 8:21am    
This is pretty simple.
Simplest way is to use replace function to replace all "," to "_"
Or use split function to split the text with "," and then use a for loop to concat with "_".

I can write down the code here but I would always suggest you guys to try it yourself first. This will help you in long term.
Sergey Alexandrovich Kryukov 30-Dec-13 12:30pm    
Is it so difficult to read standard MSDN documentation?
At least read this: What have you tried?
—SA

 
Share this answer
 
C#
var strTemp = "l_1_1,2,3,4 ";
strTemp = strTemp.replace(/,/g, "_");
alert(strTemp);

Enjoy ;)
 
Share this answer
 
VB
var a ='l_1_1,2,3,4'
a=a.replace(/,/g,'_')
alert(a)



This will solve your problem...
 
Share this answer
 
 
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