Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

adding rows dynamically?

Posted on 2012-03-29
4
Medium Priority
?
306 Views
Last Modified: 2012-03-30
I am looking to add rows dynamically to a table and would like to know how I can do this? I choose the number of rows with a radio button and once I hit the submit button I would like to have a table with the specified number of rows with 8 columns and check box in the cell. Please let me know how I can do this. Thanks for the help.

A
addRow.html
addRow2.php
0
Comment
Question by:aej1973
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 31

Accepted Solution

by:
Marco Gasi earned 400 total points
ID: 37785849
You have to use a loop like this:

<?php
if (isset($_POST['Submit'])){
      $num_rows = $_POST['RadioGroup3'];
      echo "<table>";
      for ($i = 0; $i < $num_rows; $i++>){
            echo "<tr>";
            echo "<td></td>>";
            echo "<td></td>>";
            echo "<td></td>>";
            echo "<td></td>>";
            echo "<td></td>>";
            echo "</tr>";
      }
      echo "</table>";
}
?>

Cheers
0
 
LVL 111

Assisted Solution

by:Ray Paseur
Ray Paseur earned 300 total points
ID: 37788301
Just a quick look a the HTML and PHP suggest to me that you might be able to get a better design if you use one of the jQuery automations for dates.  You might also want to learn about using arrays in both HTML forms and PHP.

Some jQuery information here:
http://jqueryui.com/demos/datepicker/

PHP arrays:
http://us2.php.net/manual/en/language.variables.basics.php
http://us2.php.net/manual/en/language.variables.external.php
http://us2.php.net/manual/en/language.types.array.php
http://us2.php.net/manual/en/array.sorting.php

HTML checkboxes:
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/A_5450-Common-Sense-Examples-Using-Checkboxes-with-HTML-JavaScript-and-PHP.html
0
 

Author Comment

by:aej1973
ID: 37789084
Thank you very much!
0

Featured Post

Command Line Tips and Tricks

The command line is a powerful tool at the disposal of every Linux user. Although Linux distros come with beautiful user interfaces, it's worthwhile to learn the command line because it allows you to do a number of things that you otherwise cannot do from the GUI.  

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
In this blog, we’ll look at how improvements to Percona XtraDB Cluster improved IST performance.
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question