[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

html select storing more than one value against an option

Posted on 2009-05-11
4
Medium Priority
?
293 Views
Last Modified: 2012-05-06
Hi all,

I would like to be able to show a select box on my webpage which shows names. Against each name I would like to store a code AND a short description. Can this be done?

Thanks

Duncan
0
Comment
Question by:DuncanRichardson
  • 3
4 Comments
 
LVL 41

Expert Comment

by:HonorGod
ID: 24353420
Well, you could have a data structure (e.g., a dictionary) that could be used to hold whatever information that you want/need that was associated with the select options.

For example, the dictionary key could be the names from the select list, and the value could be the code and description.

Does this make sense?
0
 

Author Comment

by:DuncanRichardson
ID: 24353454
Can this be done in javascript?
0
 
LVL 41

Accepted Solution

by:
HonorGod earned 375 total points
ID: 24353483
Something like this perhaps?h
<html>
<head>
<title> Extra Select stuff </title>
<script type="text/javascript">
  var stuff = { 'Tom'  : [ 1.23, 'Tom stuff' ],
                'Dick' : [ 3.45, 'Dick stuff' ],
                'Harry' : [ 5.67, 'Harry stuff' ]
              }
 
  function pick( name ) {
    alert( name + ' -> ' + stuff[ name ] )
  }
</script>
</head>
<body>
 <select onchange='pick(this.options[this.selectedIndex].value)'>
   <option value=''>Pick...</option>
   <option>Tom</option>
   <option>Dick</option>
   <option>Harry></option>
 </select>
 
</body>
</html>

Open in new window

0
 
LVL 41

Expert Comment

by:HonorGod
ID: 24430625
Thanks for the grade & points.

I'm sorry that you didn't think the answer warranted and A.

Good luck & have a great day.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Sometimes MS breaks things just for fun... In Access 2003, only the maximum allowable SQL string length could cause problems as you built a recordset. Now, when using string data in a WHERE clause, the 'identifier' maximum is 128 characters. So, …
Most folks would know the basics of how Dropbox works, so that’s not the purpose of this article. Security is what it’s all about, so here I’ll share how I choose to secure my Dropbox Account and the Data it contains.
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Suggested Courses

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question