2

i am working on a form where i have to get value from jquery spinner and add that number of rows to the table inside form but i dont know where is the issue exactly as i fire bug it as well but it do not show me any error.

below is my html

<div class="order-listing">
    <table id="my-table">
        <tbody>
            <tr><td>
                <input type="text" name="name" />&nbsp;&nbsp;
                <input type="text" name="name" />&nbsp;&nbsp;
                <input type="text" name="name" />
                <select>
                    <option value"">abc</option>
                    <option value"">abc</option>
                    <option value"">abc</option>
                    <option value"">abc</option>
                </select>     
            </td></tr>              
        </tbody>
    </table>                  
</div>

and below is the jquery code for addition of rows

<script>
 $(function() {
    var spinner = $( "#spinner" ).spinner({ min: 0 });
    $( "#ok" ).click(function() {
        var spiner_val = spinner.spinner( "value" ) ;
        var html = '<tr><td><input type="text" name="name" />'+
                    '<input type="text" name="name" /><input type="text" name="name" />'+
                    '<select><option value"">abc</option><option value"">abc</option>'+
                    '<option value"">abc</option><option value"">abc</option></select></td></tr>';

        $('#my-table > tbody > tr').eq(spiner_val).after(html);
    });
    $( "button" ).button();
});
</script>

below is the spinner and the ok button which trigger this functionality

<p>
    <label for="spinner">New Lines Required:</label>
    <input id="spinner" name="value" />
    <input type="button" value="OK" id="ok" />
</p>
3
  • 1
    why down votingggggg?????? Commented Sep 17, 2013 at 12:13
  • 3
    Someday , at some universe -- the Stackoverflow programmers- will be smart enough to not allow downvote without any comment. Commented Sep 17, 2013 at 12:18
  • 1
    @kwk.stack: Some people are sitting here just to do these kind of stuff only. They have must reputation (points) so they start spending now. :P Commented Sep 17, 2013 at 12:24

1 Answer 1

4

Try this, use a for loop and add the html

 for(i = 0; i < spiner_val;i++){
     $(html).insertAfter('tr:last');
 }

DEMO

Sign up to request clarification or add additional context in comments.

3 Comments

yes it worked thanks alot but down voting by programmers for this question realy disheart me
@kwk.stack You're welcome btw option value"" should be value="". Got no idea why your question got downvoted :/
ohhh thank you so much for correction as well :) i know i can get upvoting on a question like "what are the spellings of fox??" becuse the question i asked above was not acceptable

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.