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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T23:24:22+00:00 2026-06-16T23:24:22+00:00

I am still learning javascript and I have problem with my current application From

  • 0

I am still learning javascript and I have problem with my current application
From this fiddle, it’s not working but it can roughly show what I want to achieve.

My output if I chose Banana & Mouse will be:
Banana is yellow
Mouse is small

I want to know how I can call the second function with just one click of the button, and how can I reuse my codes in this case as I have another 5 more select options at the end it.

Thanks!

  • 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-16T23:24:24+00:00Added an answer on June 16, 2026 at 11:24 pm

    You can just pass the ids as parameters to the function and manipulate each element value accordingly.

    function displayResult (fruitId,sizeId) {
        var selTag = document.getElementById(fruitId);
        var fruit=selTag.options[selTag.selectedIndex].text;
        if (fruit=="Apple") {
          fruit = fruit + " is red";
        } else if (fruit=="Orange") {
          fruit = fruit + " is orange";
        } else if (fruit=="Banana") {
          fruit = fruit + " is yellow";
        }
        selTag = document.getElementById(sizeId);
        var animal=selTag.options[selTag.selectedIndex].text;
        if (animal=="Elephant") {
          animal = animal + " is big";
        } else if (animal=="Mouse") {
          animal = animal + " is small";
        } else if (animal=="Whale") {
          animal = animal + " is enormous";
        }
        document.getElementById('mytextbox').value = fruit+"\n"+animal;;
    }
    

    DEMO

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

Sidebar

Related Questions

I know this question has asked before, but I'm still learning JavaScript, and I'm
I'm still learning JQuery (and as a result a little JavaScript) but I can't
This is probably very elementary, but I'm still learning. I've imported a record from
Sorry if this sounds silly, I am still learning server-side Javascript. I have this
I have a simple request(still learning javascript). I have a title div and 3
Still learning JSP Web Applications here. I have been doing this for a while
I'm definitely still learning Javascript so please forgive me if this is a very
I'm still learning JavaScript,reading books,utilizing FireBug,experimenting. I'm amazed and stuck on thing below. Have
Hi I am still learning Jquery and have a problem accessing form elements. My
Learning Javascript and have a question about global variables. From my reading, most recommend

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.