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

Posted on 2011-11-01
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

    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

    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.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Someone recently asked me about how to display a progress indicator on a page while an iframe is loading. And I remember when I first came across this myself. It was a bit tricky to get my head around, but really, it's very simple. The most impor…
    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.
    The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
    The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

    759 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

    11 Experts available now in Live!

    Get 1:1 Help Now