Add Group of Form Elements Dynamically

Add Group of Form Elements Dynamically

I'm building a custom component in Joomla. All the Jquery up till now is working just fine.

I'm not sure if I'm using the wrong keywords or what, but I'm not having much success finding a way to make the following happen:

I have a form that asks for a bunch of information. First it's name, etc... Then it asks for vehicle information: The code for that is this:
  1.                 <table class="rsmformtable contentpaneopen">
                        <tr>
                            <td colspan="2">
                                <div class="rsmformtablediv">
                                    VEHICLE #01:<br />
                                </div>
                            </td>
                        </tr>
                        <tr>
                            <th>
                                <label for="plan_type">Choose A Plan:</label>
                            </th>
                            <td>
                                <select name="plan_type" id="plan_type">
                                    <?php
                                        $db =& JFactory::getDBO();
                                        $query = 'SELECT plan_type, plan_price, category FROM jos_rsm_plantypes';
                                        $db->setQuery($query);
                                        $results = $db->loadAssocList();

                                        foreach($results as $row){
                                            echo "<option value=" . $row[category] .">" . $row[plan_type] . " $" . $row[plan_price] . "</option>";
                                        }
                                    ?>
                                </select>
                            </td>
                        </tr>
                        <tr>
                            <th>
                                <label for="car_year">Please Enter The Vehicle's Year:</label>
                            </th>
                           
                            <td>
                                <select name="year" id="year">    
                                <?php
                                    $currentyear = date('Y');
                                    $endyear =  $currentyear + 1;

                                    $years = range ($endyear, 1950);
                                    foreach ($years as $value) {
                                        echo '<option value="' . $value . '">' . $value . '</option>';
                                    }
                                ?>
                                </select>
                            </td>
                        </tr>
                        <tr>
                            <th>
                                <label for="car_make">Please Enter The Vehicle's Make:</label>
                            </th>
                           
                            <td>
                                <input type="text" id="car_make" name="car_make" class="required" minlength="2" />
                            </td>
                        </tr>
                        <tr>
                            <th>
                                <label for="car_model">Please Enter The Vehicle's Model:</label>
                            </th>
                           
                            <td>
                                <input type="text" id="car_model" name="car_model" class="required" minlength="2" />
                            </td>
                        </tr>
                        <tr id="truckvinrow">
                            <th>
                                <label for="truckvin">Please Enter Last 6 Of Truck VIN:</label>
                            </th>
                           
                            <td>
                                <input type="text" id="truckvin" name="truckvin" class="" minlength="6" />
                            </td>
                        </tr>
                    </table>









































































So, what I want to happen is that there is an add vehicle link or button so that when someone hits it, it allows them to add in another vehicle. Of course it should also add some index to the id's of all the inputs as I will use the post data to add the vehicles to a database.

Now at first I thought I had found a solution, that works a little bit. But then when the PHP comes into effect things break.

Also, this is an aside: the truck vin row is controlled by jquery now. If the plan type selected is for a truck, it will show that row, if it's not then that row is hidden. I'm pretty sure I'll need to build a loop in the Jquery script that will allow that hide and show feature to work based on the index added to the truck row.

in my searching, the only thing I've really been able to find is that I might have to use AJAX, but that's not something I familiar with just yet.

Anyways, any help anyone can give me would be greatly appreciated. Please feel free to request additional code if you need.