jQuery - radiobutton gets unselected

Camillia
Camillia used Ask the Experts™
on
I have one last problem with this code....

1. You can see the code here https://drive.google.com/open?id=1uZAdMSnw0QrfjJbhijqeDu2NQTk5wFi4
click on page.html

2.  Page loads and you see the radiobutton checked
r1.png
3. Click on Add and another row is added but now, the first radiobutton is unchecked.
r2.png
4. I checked the "id" and "name" and they're unique. Not sure why this is happening. I'll continue working on it. If I figure it out, I'll post back.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Multitechnician
Top Expert 2014
Commented:
radio button with the same name are exclusive (mean if one is checked the previous one with the same name is unchecked)
when you append the template, you add radio button with the same name ( index 0 ) so the previous one (the first one is unchecked)
just remove the name attribute and as you're cloning, don't put ID attribute inside your template too. It's just a good practice to not use the ID attribute useless in your case.

so just replace :
								<div class="radio">


																<label>

																	<input type="radio" id="Schedules[0]IsExcelExportCSV" value="false" name="Schedules[0].IsExcelExport" class="radio1">
																	CSV
																</label>

															</div>
															<div class="radio">
																<label>
																	<input type="radio" id="Schedules[0]IsExcelExportExcel" checked="checked" value="true" name="Schedules[0].IsExcelExport" class="radio2">
																	Excel
																</label>

															</div>

Open in new window

by :
					<div class="radio">
						<label>
							<input type="radio" value="false" class="radio1">
							CSV
						</label>
					</div>
					<div class="radio">
						<label>
							<input type="radio" checked="checked" value="true" class="radio2">
							Excel
						</label>
					</div>

Open in new window

Let me see.
Don't think it's working right but let me play around with it. I'll post back.
Ensure you’re charging the right price for your IT

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

leakim971Multitechnician
Top Expert 2014

Commented:
work fine on my side...
Let me try it again.
Works. I think I needed to clear the cache. Thanks agian.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial