var max_fields = 9;
var $setting = $("#settingA");
//var $maincontent = $("#mainContent");
// Add html controls
for (var i = 1; i < max_fields; i++) {
var checkedElements = [];
$setting.append("<span style='margin:10px; line-height:2;'><label style='margin-right:10px;'>Channel " + i + "</label><input type='text' name='product_" + i + "' id='product_" + i + "'/></span>");
checkedElements.push($('input[name="product_' + i + '"]').val());
}
Add a comment
|
3 Answers
in HTML:-
<input type='text' class='product' name='product_" + i + "' id='product_" + i + "'/>
and in jQuery :-
$('.product').each(function() {
var product = $(this).val();
alert(product);
});
5 Comments
Chinnu Kar
How to save this value to channelSettings.txt file
Chinnu Kar
How to save this value to channelSettings.txt file onclcik of button
Chinnu Kar
How save this input value to channelSettings.txt file. Already existing txt file
Neel
trying to update answer but some errors coming while updating
Neel
meanwhile see this jquery.tiddlywiki.org/twFile.html and stackoverflow.com/questions/6964059/…
Try like this using starts with selector...
$("input[name^='product_']").each(function() {
var textVal = $(this).val();
alert(textVal);
});
2 Comments
Chinnu Kar
input[name^='product_'] it's showing input is not aaviable
John R
Surely it will work. Receiving any console error from your side?
Instead of
$('input[name="product_' + i + '"]').val()
try:
$('body').find('input[name="product_' + i + '"]').val()
2 Comments
Chinnu Kar
How to get dynamic created text box value in jquery or javascript onclick of button i want value
Siamak Ferdos
@Chinnu Kar: Why did you repeat your question title?