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 9249745
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T10:16:31+00:00 2026-06-18T10:16:31+00:00

I got confused at some point in my project. The thing I am trying

  • 0

I got confused at some point in my project.
The thing I am trying to make here is as following:

Get data from the database
Create a new select box with the button – create
Populate this select box with values from the database
Option to delete that select box through the button – delete

The code I have so far PHP/HTML:

   <button type="button" name="add" onclick="return false;" id="addField" class="nice_button">Добавить(ADD)</button>


   <button type="button" name="remove" onclick="return false;" id="remove" class="nice_button">Удалить(DELETE)</button>


 <tbody id="documentFields">
 <tr>
    <td>
        <select size="1" name="hardware[]" style='width:400px;'>
        <option value=""></option>
        <?php   while($hardware = $get_hardware->fetch_array()){
          echo "<option  value='".$hardware['st_id']."'>".$hardware['st_name']." ".$hardware['st_producer']." ".$hardware['st_model']."</option>";
        }
        ?>
        </select>
    </td>
</tr>
</tbody>

JS script I have so far looks like that:

var g = 1;
var id = [ <? php echo $js_id; ?> ];
$(document).ready(function Product_add() {
    $("#addField").click(function () {
        $("#documentFields").append('<tr id="fieldset_p' + g + '"><td><select size="1" name="hardware[]" style="width:400px;"><option value=""></option></select></td></tr>');
        g++;
    });
});
$(document).ready(function Product_add() {
    $('#remove').click(function () { // similar to the previous, when you click remove link
        if (g > 1) { // if you have at least 1 input on the form
            g--; //deduct 1 from i so if i = 3, after i--, i will be i = 2
            $('#fieldset_p' + g + '').remove(); //remove the last fieldset  
        }
    });
});

The thing is that I cannot append php function: while, so I cannot populate this select box as the one before.

  • 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-18T10:16:33+00:00Added an answer on June 18, 2026 at 10:16 am

    In this case you could use Ajax.

    What’s ajax:

    http://en.wikipedia.org/wiki/Ajax_(programming)

    It’s providing a page with just your information in a specific format. Then call it with your javascript and then parse it into the page.

    Documentation how to do this in jquery:

    http://api.jquery.com/jQuery.ajax/


    Update:

    Code example:

    $.get('ajax/test.html', function(data) {
    
        // read in data = = [{'option':'option 1'},{'option':'option 2'}]
    
          $.each(data, function(index, itemData) {
           /// do stuff
             $('<option>' + itemData.option + '</option>').appendTo('#myselectbox');
          });
    
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I got confused with Git !! I have some files which have added and
I have the following code and got myself confused: I have a query that
I was tampering with Expressions and I got confused at some points We can
I'm trying to compile X11R6-7.0 under Ubuntu maverick and got some weird compilation errors
I am trying to create some modal windows to appear whenever the user wants
I found the following code here: http://en.wikipedia.org/wiki/Double-checked_locking#Usage_in_Java I am trying to understand why there
Starting some PHP and confused by the way echo/print are working. I've got this
I wrote some java classes, to evaluate/demo different Sorting algorithms. However I got confused
I'm a beginner in Javascript. And while trying recursion by myself, i got some
Would like some advice from this. I got a table where I want to

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.