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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T21:01:52+00:00 2026-05-22T21:01:52+00:00

I have a dropdown which when an option is selected it needs to populate

  • 0

I have a dropdown which when an option is selected it needs to populate an input value with the value of the option selected only its not working as in nothings changing, Could anybody see and explain why going of my code?

 <select id="corr_sel" onchange="updatecredoff();"> 
    <option value="1">1</option>
    <option value="2">2</option>
    <option value="3">3</option>
    <option value="4">4</option>
    <option value="5">5</option>
    <option value="6">6</option>
    <option value="7">7</option>
    <option value="8">8</option>
    <option value="9">9</option>
    <option value="10">10</option>
 </select>

<div id="cr_off"><?php echo $user_curr_coff;?></div>

function updatecredoff() {
    if(value == 1) {
        document.getElementById("corr_sel").value = '1';
        document.getElementById("cr_off").innerHTML = '1';
        }
    else if(value == 2) {
        document.getElementById("corr_sel").value = '2';
        document.getElementById("cr_off").innerHTML = '2';
        }
    else if(value == 3) {
        document.getElementById("corr_sel").value = '3';
        document.getElementById("cr_off").innerHTML = '3';
        }
    else if(value == 4) {
        document.getElementById("corr_sel").value = '4';
        document.getElementById("cr_off").innerHTML = '4';
        }
    else if(value == 5) {
        document.getElementById("corr_sel").value = '5';
        document.getElementById("cr_off").innerHTML = '5';
        }
    else if(value == 6) {
        document.getElementById("corr_sel").value = '6';
        document.getElementById("cr_off").innerHTML = '6';
        }
    else if(value == 7) {           
        document.getElementById("corr_sel").value = '7';
        document.getElementById("cr_off").innerHTML = '7';
        }
    else if(value == 8) {
        document.getElementById("corr_sel").value = '8';
        document.getElementById("cr_off").innerHTML = '8';
        }
    else if(value == 9) {
        document.getElementById("corr_sel").value = '9';
        document.getElementById("cr_off").innerHTML = '9';
        }
    else {
        document.getElementById("corr_sel").value = '10';
        document.getElementById("cr_off").innerHTML = '10';
    }
    };
  • 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-22T21:01:53+00:00Added an answer on May 22, 2026 at 9:01 pm

    You haven’t defined value anywhere in your code (at least from what you’ve shown) before this:

    if(value == 1) {
    

    You could define onchange="updatecredoff(this); with this attached, and then in your function before your first conditional assign the value:

    function updatecredoff(e) {
        value = e.value;
    

    Example:
    http://jsfiddle.net/niklasvh/yXHD5/

    Or you could just get the value by the ID like this:

    value = document.getElementById("corr_sel").value;
    

    If that is all the functionality you intend to do with the function, you could simplify it to just:

    function updatecredoff(e) {
        document.getElementById("cr_off").innerHTML = e.value;   
    };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have dropdown menu..which is dynamic.. How can get value of the last item
I have a dynamically generated Dropdown for which I need to change the selected
I have two dropdowns Dropdown 1 <form:select path=StartTimings id=startTime onchange=javascript:changeTiming()> <form:option value=9:00 AM>9:00 AM</form:option>
I have dropdown very similar to this: <select id='someSelect'> <option value=0>---select one---</option> <optgroup label=Bikes>
I have a dropdown list (FK) which I would like to set and display
I am having a project which will have country dropdown at the top to
I have a little dropdown menu similar <select> , which contolled from external js-function.
I have a UserControl A which contains a dropdown a placeholder At runtime the
I have a website on with MVC, which has a dropdown in the masterpage.
I have a dropdown list that stores name/value pairs. The dropdown appears in each

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.