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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T12:15:59+00:00 2026-06-05T12:15:59+00:00

I have a form with 2 selection boxes, both of these boxes draw their

  • 0

I have a form with 2 selection boxes, both of these boxes draw their options from my database through php.

The first one shows a list of books ordered by their ISBN like this:

<ISBN> - <Book name>

Now the second selection box will list all the editions that exist for the book selected in the previous selection (based on ISBN) and show each one of them with just the number of the edition.

What I do in this form is insert a specific copy of the selected book with the specific edition with its serial number in the database.

What I try to do is with the onChange to retrieve the ISBN selected from the first select and use it to show the options of the second selection.

I use the function dropdown() to display the book select and the dropdownEdition() for the edition select:

function dropdown($intIdField, $strNameField, $strTableName, $strOrderField, 
         $strNameOrdinal, $strMethod="asc") {
   echo "<select name=\"$strNameOrdinal\">\n";
   echo "<option value=\"NULL\">Select Value</option>\n";
   
   $strQuery = "select $intIdField, $strNameField
               from $strTableName
               order by $strOrderField $strMethod";

   $rsrcResult = mysql_query($strQuery);

   while($arrayRow = mysql_fetch_assoc($rsrcResult)) {
       $strA = $arrayRow["$intIdField"];
       $strB = $arrayRow["$intIdField"] . " - " . $arrayRow["$strNameField"];
       echo "<option value=\"$strA\">$strB</option>\n";
   }
   echo "</select>";
}

function dropdownEdition($intId1Field, $intId2Field, $strTableName, $strOrderField, 
         $strNameOrdinal, $strMethod="asc") {      
    
   echo "<select name=\"$strNameOrdinal\">\n";
   echo "<option value=\"NULL\">Select Value</option>\n";
   
   $strQuery = "SELECT $intId1Field, $intId2Field
               FROM $strTableName
               ORDER BY $strOrderField $strMethod";

   $rsrcResult = mysql_query($strQuery);

   while($arrayRow = mysql_fetch_assoc($rsrcResult)) {
       $strA = $arrayRow["$intId1Field"];
       echo "<option value=\"$strA\">$strA</option>\n";
   }

   echo "</select>";
}

What I basically want to do is pass the ISBN selected previously with the onChange, in the variable $intId2Field of the dropdownEdition().

The problem with that is I have searched for tutorials but I can’t understand anything because I have never worked with jQuery or Javascript or AJAX and I am a very novice web programmer. That is the reason for I am asking for some help here.

Here are how the 2 functions are called:

 <?php dropdown("book_ISBN", "book_title", "book", "book_ISBN", "book"); ?>

 <?php dropdownEdition("edition_no", "???????", "edition", "edition_no", "edition"); ?>`

The ???? are the book_ISBN because I don’t know how to pass it in.

Here are how the tables are connected:

enter image description here

References –

  • 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-05T12:16:00+00:00Added an answer on June 5, 2026 at 12:16 pm

    It sounds like you’ve already figured this out, but you will need to make an asynchronous request to the server, passing the ISBN to a PHP script which will execute your mySQL query.

    Your PHP script would return the mysql results, possibly as a JSON object which could then be parsed using JS and formatted as HTML.

    Here is some code I chucked together to demonstrate.

    HTML:

    <select name="isbn-select" id="isbn-select">
      <option value="">Select an ISBN</option>
      <option value="isbn1">isbn1</option>
      <option value="isbn2">isbn2</option>
      <option value="isbn3">isbn3</option>
    </select>
    

    JS:

    $('#isbn-select').on('change', function() {
      isbn = $('#isbn-select').val();
      $.getJSON('get_editions.php',
      {
      isbn: isbn
      },
      function(data) {
        var editions = [];
        $.each(data, function(index, val) {
          editions.push('<option value="' + val + '">' + val + '</option>');
        });
        $('<select/>', {
          'id': 'editions-select',
          'name': 'editions-select',
          html: editions.join('')
        }).appendTo('body');
      });
    });
    

    PHP:

    <?php
    // Code to select editions from your database goes here....
    // Your isbn can be accessed as $_GET['isbn']
    $editions_arr = array('editon1', 'edition2', 'edition3');
    echo json_encode($editions_arr);
    ?>
    

    I have used jQuery’s getJSON method to fetch a JSON object from get_editions.php. The results are then formatted as a select and appended to the HTML document. To keep things simple I am not doing any error checking or validation.

    I hope this helps get you on the right track!

    EDIT:

    If you wish to return formatted HTML instead of a JSON object, here’s how you can do that.

    JS:

    $('#isbn-select').on('change', function() {
      isbn = $('#isbn-select').val();
      $.get('get_editions.php',
      {
      isbn: isbn
      },
      function(data) {
        $('body').append(data);
      });
    });
    

    PHP:

    <?php
    // Code to select editions from your database goes here....
    // Your isbn can be accessed as $_GET['isbn']
    $editions_html = '<select id="editions-select" name="editions-select">';
    $editions_html .= '<option value="edition1">edition1</option>';
    $editions_html .= '<option value="edition2">edition2</option>';
    $editions_html .= '<option value="edition3">edition3</option>';
    $editions_html .= '</select>';
    echo $editions_html;
    ?>
    

    You can read up on jQuery’s AJAX functions here: http://api.jquery.com/category/ajax/

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

Sidebar

Related Questions

I have a form containing some dynamic elements. These are basically text input boxes
I have two sections on my PHP form. One section allows to enter Customer
I have a problem with element selection, i have a form and i want
I have a registration form with common registration fields and two multiple selection Lists
I have a form where a user can add multiple select boxes for multiple
I have django form which displays the check boxes.After selecting the checkboxes user will
I have a script to check/uncheck all boxes on a form in a grails
I am trying to loop through some elements in a form (radios, text boxes,
I have a web form with two drop-down boxes, and I'm looking for a
I have a series of select boxes whose content is dynamically defined, the options

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.