1
 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());   
    }

3 Answers 3

2

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);
         });
Sign up to request clarification or add additional context in comments.

5 Comments

How to save this value to channelSettings.txt file
How to save this value to channelSettings.txt file onclcik of button
How save this input value to channelSettings.txt file. Already existing txt file
trying to update answer but some errors coming while updating
1

Try like this using starts with selector...

$("input[name^='product_']").each(function() {
       var textVal =  $(this).val();
       alert(textVal);
     });

2 Comments

input[name^='product_'] it's showing input is not aaviable
Surely it will work. Receiving any console error from your side?
0

Instead of

$('input[name="product_' + i + '"]').val()

try:

$('body').find('input[name="product_' + i + '"]').val()

2 Comments

How to get dynamic created text box value in jquery or javascript onclick of button i want value
@Chinnu Kar: Why did you repeat your question title?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.