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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T02:52:46+00:00 2026-05-11T02:52:46+00:00

Thanks for reading this. I would have thought it would be as simple as

  • 0

Thanks for reading this.

I would have thought it would be as simple as using the .split function on the select .val(), but I get a js error. This is the code I am using. I will use .each() to loop through the selected items…but would like to understand what I am doing wrong…

If I set opts with a literal..the split works (commented code)

Thanks

<html><head> <script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js'></script> <script type='text/JavaScript'> $(function(){     $('#multOpts').bind('click', function() {     //  var opts = 'OPT1,OPT2,OPT3' ;         var opts = $('#select1').val() ;         $('#text1').val(opts);     });     $('#oneOpt').bind('click', function() {         //  var opts = 'OPT1,OPT2,OPT3' ;         var opts = $('#select1').val() ;         var optsArray = opts.split(',') ;         $('#text2').val('1st opt: ' + optsArray[0]);     }); }); // End eventlistener </script> </head><body> <select id='select1' multiple size='5'> <option value='OPT1'>Option 1</option> <option value='OPT2'>Option 2</option> <option value='OPT3'>Option 3</option> <option value='OPT4'>Option 4</option> <option value='OPT5'>Option 5</option> </select> <div> <input id='multOpts' type='button' value='Show Options'/> <input id='text1' type='text'/> </div> <input id='oneOpt' type='button' value='One Option'/> <input id='text2'  type='text'/> </body></html> 
  • 1 1 Answer
  • 1 View
  • 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. 2026-05-11T02:52:46+00:00Added an answer on May 11, 2026 at 2:52 am

    The val() function when there are more than one option selected returns you already an array, you don’t need to do the split.

        $('#oneOpt').bind('click', function() {             var opts = $('#select1').val();             $('#text2').val('1st opt: ' + opts[0]);     }); 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 142k
  • Answers 142k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Lists and dictionaries are containers that don't support a queue… May 12, 2026 at 8:17 am
  • Editorial Team
    Editorial Team added an answer The first form is well (CONTAINS(myColumn, '"Online*" and "sql*" and… May 12, 2026 at 8:17 am
  • Editorial Team
    Editorial Team added an answer Ok, i figured it out. <mx:Canvas id="swfHolder" mask="{maskCanvas}"> <mx:SWFLoader id="swffer"… May 12, 2026 at 8:17 am

Related Questions

Let's suppose I have an interface named Controller. Several classes implement this interface and
I am working on a simple notification service that will be used to deliver
I want to add the ability for the users to capture the current screen
I'm really interested in speech-to-text algorithms, but I'm not sure where to start studying

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.