Solved

html select storing more than one value against an option

Posted on 2009-05-11
4
281 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
Comment Utility
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
Comment Utility
Can this be done in javascript?
0
 
LVL 41

Accepted Solution

by:
HonorGod earned 125 total points
Comment Utility
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
Comment Utility
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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Possible fixes for Windows 7 and Windows Server 2008 updating problem. Solutions mentioned are from Microsoft themselves. I started a case with them from our Microsoft Silver Partner option to open a case and get direct support from Microsoft. If s…
HOW TO: Connect to the VMware vSphere Hypervisor 6.5 (ESXi 6.5) using the vSphere (HTML5 Web) Host Client 6.5, and perform a simple configuration task of adding a new VMFS 6 datastore.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

771 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now