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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T18:28:48+00:00 2026-06-15T18:28:48+00:00

I am using an API to get data from a mySQL database in a

  • 0

I am using an API to get data from a mySQL database in a JSON format and I show the data in a datatable. What I am doing is to edit something I am showing a modal with the data to edit. It has a dropdown as well. I am confused as I don’t know how to populate them with the values from database, I have tried everything till now but still I am not successful.

Here’s the script,

$('#company .edit-company').live('click', function() {
                    var id = $(this).attr('id');
                    $('#company-label').html('Edit ');
                    $('#company-form')[0].reset();
                    $.ajax({
                        url : '/index.php/company/profile_data',
                        type : 'POST',
                        data : 'companies[]=' + id,
                        beforeSend : function() {
                            $('#loading-span7').show();

                        },
                        success : function(data, textStatus, xhr) {

                            var details = JSON.parse(data);
                            console.log(details.aaData[0].homepage_url);
                            $('input[name=company-name]').val(details.aaData[0].name);
                            $('input[name=package-id]').html(details.aaData[0].package_id);
                            //$('#package-id').val(details.aaData[0].package_id);
                            $('#edit_company').modal('show');
                            $('#loading-span7').fadeOut();
                        },
                        error : function(xhr, textStatus, errorThrown) {
                            //alert('error');
                        }
                    });

                });

And here’s the HTML

<div id="edit_company" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                ×
            </button>
            <h3 id="myModalLabel"><span id="company-label"></span>Company</h3>
        </div>
        <div class="modal-body">
            <form id="company-form">
                <fieldset>
                    <label>Name</label>
                    <input type="text" placeholder="Type something…" name="company-name">
                    <label>Package</label>
                    <select name="package" name="package-id" id="package-id">
                        <option></option>
                    </select>

                </fieldset>
            </form>

        </div>
        <div class="modal-footer">
            <button class="btn" data-dismiss="modal" aria-hidden="true">
                Close
            </button>
            <button class="btn btn-primary">
                Save changes
            </button>
        </div>
    </div>
  • 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-15T18:28:49+00:00Added an answer on June 15, 2026 at 6:28 pm
    $('select#package-id option').text(details.aaData[0].package_id);
    

    to create options:

    var option1 = $('<option />', {text: details.aaData[0].package_id}),
        option2 = $('<option />', {text: details.aaData[1].package_id}),
        option3 = $('<option />', {text: details.aaData[2].package_id});
    
    $('select#package-id').append(option1, option2, option3);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using ASIHTTPRequest API to get some JSON data from a web side. I'm
I'm trying to get some data from a certain web-based api using the libcurl
I am using API to get data from CMS, we are displaying text what
I tried get data from rest api using http requests and evenmachine. For this
I am using a API to get some data from curl. Response i get
I have to import data from a CSV file into MySQL database using JSP/Servlet.
I'm using the python module requests to get data from some API's and they
I'm doing AJAX calls to get data from the last.fm API and decided to
I am using google api to get search result for certain queries in JSON
I'va got a jquery file processing some mysql-data changes using ajax-calls (jQuery api) within

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.