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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T14:46:37+00:00 2026-05-13T14:46:37+00:00

I am pretty new to javascript so I hope someone here can help me

  • 0

I am pretty new to javascript so I hope someone here can help me out with this little task.

I currently have two input text fields that I need to be populated with text after selecting an option from a drop down menu.

For example…

I have a select field that looks like this:

<select id="select_2" onchange="insertProduct(2);">

And within that select I have options that look like this:

<option id="cdrom001" title="my cdrom">cdrom001 - my cdrom</option>
<option id="DVD-ABUG" title="A Bug's Life">DVD-ABUG - A Bug's Life</option>
<option id="DVD-BELOVED" title="Beloved">DVD-BELOVED - Beloved</option>
....

What I want to happen, is when I select an option from that drop down list, I want my text input field #1 to be populated with the option id (eg. DVD-ABUG) and I want my text input field #2 to be populated with the option title (eg. A Bug’s Life).

Here is the code for my two text input fields:

<input type="text" name="model[]" id="model_2">
<input type="text" name="product[]" id="product_2">

I have this much written of the function that will be required to do this…

function insertProduct(id){ 
// code goes here
}

As you can see, I don’t have much. :o)

Can someone please help me with the function that can do this?

Thanks so much!

  • 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-05-13T14:46:37+00:00Added an answer on May 13, 2026 at 2:46 pm

    Change this line:

    <select id="select_2" onchange="insertProduct(2);">
    

    to this:

    <select id="select_0" onchange="insertProduct(this, 0);">
    

    and use this function:

    function insertProduct(select, row){ 
        var model = "model_";
        var product = "product_";
        document.getElementById(model + row).value = select.options[select.selectedIndex].id;
        document.getElementById(product + row).value = select.options[select.selectedIndex].title;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I hope someone can help me. I have a website that uses javascript to
I'm pretty new to javascript. I have this sample table. I want to be
Okay, I'm hating Javascript right now, and I hope someone can help me. I
I'm pretty new with Javascript and jQuery and can't quite figure out settimeout .
I'm pretty new to Javascript, so bear with me if this is obvious. Basically
I'm pretty new to Javascript, so forgive me if this is a simple question.
Hi I'm pretty new to javascript looking for some help on creating an argument
I'm pretty new to Javascript and have been trying to achieve some fading effects
I'm pretty new to JavaScript, which I am learning on my own. I'm currently
I have just entered the world of jquery and am pretty new to javascript

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.