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

  • Home
  • SEARCH
  • 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 9213847
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T01:50:38+00:00 2026-06-18T01:50:38+00:00

I can append html form elements to a table with jquery. How can I

  • 0

I can append html form elements to a table with jquery. How can I append menus populated with php/my sql query so that the php menu is between td and input… below??

<script type="text/javascript">
$(document).ready(function() {
      $("#link td input.rdelete").live("click", function () {
              $(".newrow").attr("disabled",false);
            var srow = $(this).parent().parent();
                        srow.remove();                  
            });
});


function AddNew() { 
           if($("#link tr").length > 12) {
              $(".newrow").attr("disabled",true);
           }
           var count = 0;
           count += 1;

        $("#link").append('<tr><td></td><td> <input type=\"button\" value = \"Delete\" class=\"rdelete\"/></td></tr>' );
           }
</script>

The php menu is:

<select name="sub_discipline" id="sub_discipline">
            <option>Select Sub-discipline...</option>
            <?php 
$query = mysql_query("SELECT * from sub_discipline ORDER BY sub_discipline_name ASC");
while ($row = mysql_fetch_assoc($query)){
?>
            <option value="<?php echo $row['sub_discipline_pk']; ?>"><?php echo $row['sub_discipline_name']; ?></option>
            <?php 
}
?>
          </select>

EDIT: Thanks to Explosion Pills I now have:

<script type="text/javascript">
$(document).ready(function() {
$("#jMenu").jMenu();
      $("#link td input.rdelete").live("click", function () {
              $(".newrow").attr("disabled",false);
            var srow = $(this).parent().parent();
                        srow.remove();                  
            });
});


    function AddNew() { 
               if($("#link tr").length > 12) {
                  $(".newrow").attr("disabled",true);
               }

    $.getJSON('../scripts/link_menu.php', function (json) {
       $("#links").empty();
       $.each(json, function () {
           $("#links").append(new Option(this.link_title));
       });
    }); 

            $("#link").append('<tr><td></td><td><select name="links[]" id="links"> </select><input type=\"button\" value = \"Delete\" class=\"rdelete\"/></td></tr>' );

    </script>

Problem is that only the first appended menu is being populated.

  • 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-18T01:50:39+00:00Added an answer on June 18, 2026 at 1:50 am

    You need to disabuse yourself of the fact that PHP and JavaScript operate together. They are agnostic with respect to each other (i.e. they don’t know about each others’ existence, but they’re not willing to make an absolute claim that the other doesn’t exist).

    You can create a simple PHP script that echoes the MySQL results as JSON.

    $query = mysql_query("SELECT * from sub_discipline ORDER BY sub_discipline_name ASC");
    $rows = array();
    while ($row = mysql_fetch_assoc($query)){ $rows[] = $row; }
    echo json_encode($rows);
    

    Then, in your JavaScript:

    $.getJSON('/agnostic-php-script.php', function (json) {
       $("#sub_discipline").empty();
       $.each(json, function () {
           $("#sub_discipline").append(new Option(this.subdiscipline_name));
       });
    });
    

    You should also stop using ext/mysql, and it’s better to not append in a loop if you can avoid it.

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

Sidebar

Related Questions

When I handle HTML form elements with jQuery, I always end up with an
I have an HTML form that a user can add an arbitrary amount of
I have registration form on my website that, using jquery I append default values
I have a form that generates sortable divs. I am using .append() and .html()
http://www.frostjedi.com/terra/scripts/demo/jquery02.html According to this link elements can be moved around by doing $('#container1').append($('#container2')). Unfortunately,
HTML is <a>ref</a> I need to get <a>ref</a>text How can i do this? $('a').append('text')
Is there a command that can append one array of char onto another? Something
I would like some container that I can very efficiently append a variable amount
I can't make the delay function of jQuery works with append function. What is
I have a complex form that has a static section and one that can

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.