Perhaps OT ?

Discussion in 'Javascript' started by Mel Smith, Jan 25, 2012.

  1. Mel Smith

    Mel Smith Guest

    Hi:

    I have a (series of 4) 2-char input field(s) (vertically oriented in a
    crowded part of my screen) in which the user will input a U.S. State
    Abbreviation (e.g., AZ for Arizona), or a Canadian province (e.g., AB for
    Alberta), OR, click a key to return this correct abbreviation.

    I have, of course, a concordance file with all the correct names and
    region abbreviations.

    But, my problem:

    If my user knows that the input U.S. State name should be the correct
    abbreviation for (say) Minnesota, but does not know the abbreviation itself
    (i.e., MN), how can I show the user a drop-down list of States & Provinces,
    from which the return value will always be the proper abbreviation, and
    *not* the full State name ?

    I don't know how to configure the <Select > tag for this operation. My
    head is aching here :(

    Thanks for a kick in the pants on this one !
     
    Mel Smith, Jan 25, 2012
    #1
    1. Advertisements

  2. From http://www.w3schools.com/tags/att_option_value.asp :

    <select>
    <option value="volvo">Volvo</option>
    <option value="saab">Saab</option>
    <option value="mercedes">Mercedes</option>
    <option value="audi">Audi</option>
    </select>

    adjusted to

    You are welcome. My answer seems so obvious that I am concerned
    that I missed the point. Did I answer you correctly?

    Sincerely,

    Gene Wirchenko
     
    Gene Wirchenko, Jan 25, 2012
    #2
    1. Advertisements

  3. So what do the other mentioned fields do? Are they relevant at all?

    what do you mean by "click a key to return this correct abbreviation."
    Why use a 2 character field at all then? A select box seems
    appropriate
    If you have a dropdown list, why can't they just type the letter "M"
    and see the corresponding values? I quite confident that all major
    browsers since the late 1990's have this feature.
    Since I am American, I am a bit skeptical that other countries exist.
    As a result you'll have to help me with my ignorance/laziness on this
    fact:
    between States and Provinces, are the abbreviations unique? If so,
    just simply populate the element as such:

    <select ...>
    <option value="AB">Alabama</select>
    ...
    </select>

    If not, you'll need a way to determine Country before offering the
    ability to choose from the list.
     
    Michael Haufe (TNO), Jan 26, 2012
    #3
  4. Mel Smith

    Mel Smith Guest

    Michael said:
    So what do the other mentioned fields do? Are they relevant at all?

    what do you mean by "click a key to return this correct abbreviation."

    Hi Michael:

    I (currently) have a 2-char input text field where the user will enter a
    U.S State Abbreviation or Canadian Province 2-char abbreviation. There are
    four of these fields stacked vertically in a <td> column. The other fields
    in neighboring columns are all Name/Street/Zip-PostCode/Contact info
    related on each of the four lines of the table.

    The problem is that the user will 'know' the name of the state (usually)
    (from a hand-written form ), but *may not* know the region *abbreviation* or
    may mis-spell it.

    So, I would like to change this 2-char <input type="text"> field to a
    <select> field where the user can either (confidently) type in the 2-char
    fields, or 'click' on something to show all the various states and
    provinces, and them let her 'select' one. Then, I want to return *only* the
    correct 2-char abbreviation.
    Why use a 2 character field at all then? A select box seems
    appropriate

    Because my Database has a 2-char region field, The line is already very
    crowded (see below), and I want a 2-char state/province abbreviation
    If you have a dropdown list, why can't they just type the letter "M"
    and see the corresponding values? I quite confident that all major
    browsers since the late 1990's have this feature.

    She may not know *what* char to type or may make a mistake. If she is
    confused, I want a clickable 2-char dropdown field that will show for
    example:

    AB - Alberta
    AL - Alabama
    MN - Minnesota
    etc,
    etc,

    Then when she 'clicks on the 'AL - Alabame' option, *only* AL is
    returned.
    j>>ust simply populate the element as such:


    Yes, the Canadian provinces *are* unique, and my concordance table has
    both states and provinces, with the provinces at the bottom of the <select>
    option list along with a disabled 'Canada' line as a separator between the
    states and the provinces!


    <select ...>
    <option value="AB">Alabama</select>
    ...
    </select>

    But, then *Alabama* is returned NOT my required 'AL' (not AB which is
    Alberta, in Canada)

    So, in essence, I want my user to see in the dropdown list 'AL - Alabama',
    then clicking on it I want returned 'AL'

    Thanks for your response !

    -Mel Smith
     
    Mel Smith, Jan 26, 2012
    #4

  5. So something like this?

    <https://gist.github.com/1680706>
     
    Michael Haufe (TNO), Jan 26, 2012
    #5
  6. Mel Smith

    Mel Smith Guest

    Michael said:

    So something like this?

    <https://gist.github.com/1680706>

    Michael:

    I'll try that today- I think it will do the trick !

    So, I've downloaded it, and will digest thoroughly during tghe day, and fit
    it in to my page.

    Thank you !

    -Mel Smith
    Mesa, AZ- Arizona :))
     
    Mel Smith, Jan 26, 2012
    #6
  7. Mel Smith

    Mel Smith Guest

    Gene said:

    Hi Gene:

    Yes, I think you may have missed that I wanted the 2-char 'WA' returned,
    and not the word 'Washington' displayed on the screen after selection. I
    have a 2-char field for 'region' and I'm crowded left and right and up and
    down for landscape room

    But,. Michael Haufe has given me some sample code to look at and chew
    on, and now my head is 'abuzz' with more new ideas about this 'crowding'
    problem

    Thanks for the response !

    -Mel
     
    Mel Smith, Jan 26, 2012
    #7
  8. Mel Smith

    Tim Streater Guest

    "WA" *is* what you'd have returned.
     
    Tim Streater, Jan 26, 2012
    #8
  9. I believe what he wants is a size="2" combobox with options listed
    with full names, which is emulated by what I posted (more or less
    given styling differences per browser).
     
    Michael Haufe (TNO), Jan 27, 2012
    #9
  10. Mel Smith

    Mel Smith Guest

    I believe what he wants is a size="2" combobox with options listed
    with full names, which is emulated by what I posted (more or less
    given styling differences per browser).


    Yes, that is what I want. But, since I need 4 of these <select>
    comboboxes underneath each other in a vertical column, I need to think of
    some efficient means of just using one set of select options (i.e., fifty
    U.S. States, and ten provinces.)

    Now, I'm beginning to think, that I should leave the four 2-char <text>
    fields in place, and when focus is on any of them, I should have some way
    for the user to activate a 'click' event to bring up a single <select>
    element and its 60-odd options. Hmmmm ...

    Again, Michael has given me a solution, but I'm still puzzling over how
    to make it more efficient and less obtrusive.

    btw, I think I might place my page on one of my web sites for you folks
    to look at to give you a better perspective.

    Going golfing now -- but thinking about this :)))

    Thank y'all.

    -Mel Smith
     
    Mel Smith, Jan 27, 2012
    #10
  11. Mel Smith

    Mel Smith Guest

    Hi:

    I transferred my problem page to one of my older unused web sites, and
    massaged the page to hide real names & addresses, and stop submission, and
    to show my crowded Region fields (Rgn) near the top right of this sole page.

    You may wish to look and comment. I'll be working on it again tomorrow.

    So, if you wish, please visit: www.whosaway.com and enter the
    password: 'LOTEDIT' to see the problem page.

    Thanks,

    -Mel Smith
     
    Mel Smith, Jan 27, 2012
    #11
  12. Mel Smith

    Jeff North Guest

    You're probably wanting something like:
    http://jeffnorth.com/newsgroup/select_items.html

    The boxs 1-6 show the possible configurations for the select control.
    The textboxs with the click hyperlink is probably what you are looking
    for.
     
    Jeff North, Jan 28, 2012
    #12
  13. Mel Smith

    Mel Smith Guest

    Jeff said:

    Jeff:

    Thanks for the link, I'll check it out today.

    -Mel
     
    Mel Smith, Jan 28, 2012
    #13
  14. If you can assume that the user has a working keyboard, why not put
    in the column four <input type=text value="??" size=3 ...> (size 3 to
    show the typist that there are only two letters), and, onChange or
    otherwise, look up the entries in a 60-entry table. If any fail to
    match, then pop up a small window in which the selection may be made by
    full name, perhaps by 61 radiobuttons, all initially clear - 50 States,
    10 Provinces, and "none of those".

    BTW, are you disenfranchising those of Puerto Rico, Guam, US Samoa,
    etc.; and those of St Pierre & Miquelon etc.?
     
    Dr J R Stockton, Jan 28, 2012
    #14
  15. Mel Smith

    Mel Smith Guest

    Hi Jeff:

    Thanks for trying to help. I've got good ideas from your web site, and
    the example page.

    However, I'm not sophisticated enough to understand (completely) your
    page, or to strip out the code that I could use in my own unique situation.
    So, I'll plug on with your example and 'popups' in mind, and try to use as
    much of your code as I can.

    btw, your example *does* work on Firefox and Chrome but not on my old
    IE 7. I *do* use IE7 on my dev machine, then do final tests on Chrome,
    Safari, and FF.

    Anyway, thanks for your help. I do see a path forward using popups for
    the State/Prov selection process

    -Mel Smith
     
    Mel Smith, Jan 28, 2012
    #15
  16. Mel Smith

    Jeff North Guest

    It's the 'obj.previousElementSibling.name' that is causing the problem
    - only works in IE9.

    I've put up a revised version with lots of comments so that you may
    follow along. http://jeffnorth.com/newsgroup/select_items_2.html

    I can't test this as I only have IE9 but it should work in all
    browsers.
     
    Jeff North, Jan 29, 2012
    #16
  17. Mel Smith

    Mel Smith Guest

    Jeff said:
    HI Jeff:

    I'll download and try again late today and tomorrow.

    Thanks for helping !

    -Mel Smith
     
    Mel Smith, Jan 29, 2012
    #17
  18. Mel Smith

    Mel Smith Guest

    Dr J said:
    Yes, those fields are already there in that restricted horizontal space,
    and I would like to continue to use them with an added
    'verification/selection' process.

    Your thoughts/suggestions and those examples of Jeff North will help me
    to resolve this issue (and I hope without getting bogged down too deeply)

    Have you visited the site and looked at the current work. I'd hate to
    change the whole thing, but would like to add a bit of help.


    The last I heard was the St. Pierre and Miquelon were a part of France, and
    our Senior Park is used only by 'freezing' Canadians and Americans, and
    those hardy permanent residents who 'fry' here at 115 degrees F during the
    summer.

    Thanks for the suggestions !

    -Mel
     
    Mel Smith, Jan 29, 2012
    #18
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.