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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T14:58:47+00:00 2026-06-13T14:58:47+00:00

I checked the boards and Googled for this code but couldn’t find anything. Any

  • 0

I checked the boards and Googled for this code but couldn’t find anything. Any help would be greatly appreciated.

I have worked through a tutorial that queries a database for a car model based on the car make. In the code, the car make is hardcoded to the select while the car model is dynamic. Here’s the first part of the code:

    <?php 
    require_once("Connections/xxx.php"); // database connection

    $make = $_POST['make'];


    if ($make){
    $query= sprintf("SELECT * FROM car_model where car_model_id='$make'");
    $result = @mysql_query($query); 
    $rowModel = mysql_fetch_array($result);
    }
    ?>

Here’s the select hard code:

<select name="make" onChange="document.forms[0].submit()">
<option value="">Select Make</option>
<option value="1" <?php if(!(strcmp(1, $make))){echo "selected";}?>>Alfa Romeo</option>
<option value="2" <?php if(!(strcmp(2, $make))){echo "selected";}?>>Audi</option>
<option value="3" <?php if(!(strcmp(3, $make))){echo "selected";}?>>BMW</option>
<option value="4" <?php if(!(strcmp(4, $make))){echo "selected";}?>>Citroen</option>

And this is the dynamically populated select:

 <select name="model">
<option value="">Select Model</option>
<?php do {  ?>
<option value="<?php echo $rowModel['car_model_id']; ?>"><?php echo $rowModel['car_model']; ?></option>
<?php  }while ($rowModel = mysql_fetch_array($result));  ?>

I would like to add an onChange function to this dynamically populated select field to echo result to a textfield and I have tried many combinations but haven’t been able to figure this out. Thank you

  • 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-13T14:58:48+00:00Added an answer on June 13, 2026 at 2:58 pm

    Since you didn’t like my jquery version, which I still feel is a better answer here the javascript way which I’m sure is not going to be supported in every browser and be very buggy (thus the reason most people use jquery)

    <select name="model" onchange="update_textbox()" id="model">
        <option value="">Select Model</option>
        <?php while ($rowModel = mysql_fetch_assoc($result)){  ?>
          <option value="<?php echo $rowModel['car_model_id']; ?>">
           <?php echo $rowModel['car_model']; ?>
          </option>
        <?php  } ?>
    </select>
    <input type="text" id="model_text">
    <script>
     function update_textbox(){
      var selectbox = document.getElementById('model');
      var model = selectbox[selectbox.selectedIndex].text;
      document.getElementById('model_text').value=model ;
     }
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I try searching about this but I just can't find any that can solve
I checked the documentation, but can't seem to find what I'm looking for. I
I checked the documentation and I couldn't find a way o renaming or copying
I checked this question , but it doesn't appear to answer my problem, which
I checked this link of S.O : Pop Images like Google Images And tried
I checked throught the existing topics. I have a fix for my problem but
I checked out the three20 source and was trying to follow this guide to
I checked out TripleDES. It's block size is of 64 bits. Is there any
I checked all the topics, but i simply don't know why my script does
Checked various questions on SO, but found nothing that quite matches what I'm after...

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.