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

  • Home
  • SEARCH
  • 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 8918017
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T05:38:42+00:00 2026-06-15T05:38:42+00:00

I have a select form with different options. I want to get the value

  • 0

I have a select form with different options. I want to get the value of the option that is selected when it changes. The value has the same name of a variable that put in a function.

So I want to put the value of the selected option into my function as a variable. How should I do this?

This is my select form:

<select class="select">
    <option value="value1">option 1</option>
    <option value="value2">option 2</option>
    <option value="value3">option 3</option>
</select>

This is my JavaScript:

var value1 = ['item1', 'item2', "item3", ...]

$(".select").change(function () {
    $(".select option:selected").each(function() {
        var dataset = $(this).val();            

        d3.select(".chart")
            .selectAll("div")
            .data(dataset)
            .enter();
    });
});
  • 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-15T05:38:43+00:00Added an answer on June 15, 2026 at 5:38 am

    Instead of flooding your global scope, use an object to hold the possible combinations. reference the object with the value.

    var dataPoints = {
        value1 : ['item1', 'item2', "item3", ...],
        value2 : ['item1', 'item2', "item3", ...]
    };
    
    $(".select").change(function (){
        $(".select option:selected").each(function(){
    
              var dataset = $(this).val();          
    
                  d3.select(".chart")
                   .selectAll("div")
                   .data(dataPoints[dataset])
                   .enter();
        });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a select form element with 5 options. If option 2 is selected
The select form component in grails can have the form: <g:select name=user.age from=${0..59} value=${age}
I have this select input in my form that I want to access via
I have a form in HTML, that has several select elements, what is the
I have a select element in the form with different options. On property of
I have a select field that shows different elements of my form based on
I do have the following JavaScript. <form> <select id=sel> <option value=1>item_1</option> <option value=2>item_2</option> <option
I have some code that works and changes the style sheet using a form.
I have a simple form drop-down, and I want to display something different depending
I have an html form (each form has different page, according to date), with

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.