Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8605677
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T02:53:58+00:00 2026-06-12T02:53:58+00:00

I have select box and one table, in select box I have 1 to

  • 0

I have select box and one table, in select box I have 1 to 5 numbers if I select 2 from select box the table should be show 2 times.

Here is my code..

<script type="text/javascript">
$(document).ready(function(){
$('#Lessons').change(function(){
     var lesNum = $('#Lessons').val();
     for(k=1;k<=lesNum;k++){
         $("#xyz").css("display", "block");
     }
});
});
</script>  

and my table code is here:

<select id="Lessons" name="Lessons">
   <?php for($j=1;$j<=5;$j++):?>
       <option value="<?=$j?>"><?=$j?></option>
   <?php endfor;?>
</select>
<div id="xyz" style="display:none;">
 <table>
   //some table data goes here.
 </table>
</div>

Can anyone help me out?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T02:54:00+00:00Added an answer on June 12, 2026 at 2:54 am

    Here is what you can use:

    HTML

    <select id="Lessons" name="Lessons">
       <?php for($j=1; $j <= 5; $j++) {
            echo "<option value="$j">$j</option>";
            }
       ?> </select>
    <div id="result"></div>
    

    JavaScript

    $(document).ready(function(){
        var table = '<?php echo "<table></table>"; /* Generating the table */ ?>',
            parent = $('#result');
        $('#Lessons').change(function(){
            var lesNum = parseInt($('#Lessons').val(), 10);
            parent.empty();
            for(var k=1;k<=lesNum;k++){
                parent.append(table);
            }
        });
    });​
    

    I can recommend you to stay away from globals (k in the loop).
    ​
    And a JSFiddle example: http://jsfiddle.net/pWLhS/5/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have one table where i have select the row by checking check box.
i have one form which have some input box and some select box. i
I have a select box that is being populated dynamically from a database. As
I have a situation where I want to associate multiple values from one table
I currently have a HTML select box like below. <select name=item_1> <option value=0>Choose one...</option>
I have the following code to retain the value of a select box, which
I have a select box on a page that does a post with jQuery
I have a select box which has more than 200 items. Below the select
I have a select box on a classic ASP page which looks like this:
I have a select box that needs to submit it's value to a server

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.