select field on aspx form - can I add an additional parameter to choice? id attribute?

Posted on 2011-11-01
Medium Priority
Last Modified: 2012-05-12
I have a  basic option select field

<select id="currency-select-template" nsFld="currency">
        <option value="1">USD</option>
        <option value="2">GBP</option>
        <option value="3">CAD</option>
        <option value="4">EUR</option>

Open in new window

where I would like to assign an internal id to these choices. Can I do that with the option value 'id' attribute?

so for examply the internal id of USD would be 43, EUR would be 7, etc
Question by:sullisnyc44
LVL 20

Accepted Solution

dsacker earned 1000 total points
ID: 37063778
There is only one ID per property (or tag). Since this SELECT is a tag, the ID you assigned (currency-select-template) will be the only one that can be assigned.

If you don't have to have your values sequentially (option value="1", value="2", etc), why not just assign those the internal id you wanted to set to the ID? Then if you need to tie that ID to a country code for other reasons, you can write a javascript function to match the two and return the internal ID.

Just suggesting alternatives, since you really can't build one ID per tag.

Another option is to create a set of hidden fields that has the ID per country code.

Either would work.
LVL 53

Assisted Solution

COBOLdinosaur earned 1000 total points
ID: 37064587
There is only one ID per property (or tag).

option IS a tag and id is a global attribute that can be applied to any element.

<select id="currency-select-template" nsFld="currency">
        <option id="opt1" value="1">USD</option>
        <option  id="opt2" value="2">GBP</option>
        <option  id="opt3" value="3">CAD</option>
        <option  id="opt4" value="4">EUR</option>

Open in new window

is valid code.

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

Use these top 10 tips to master the art of email signature design. Create an email signature design that will easily wow recipients, promote your brand and highlight your professionalism.
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
In this tutorial viewers will learn how to embed Flash content in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <object> tag to embed Flash content.: To specify that the object is Flash content, d…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

862 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