Professional Web Applications Themes

OT--capturing data from select - Macromedia Dreamweaver

Background: Intranet app written in ASP. I can't show you a URL, but I'll be glad to post snippets of code. I have two select boxes, and the one on the left has been populated from the database with the names of employees. The one on the right is empty when the page loads, but when you select a name on the left, and click the right arrow button, it places the name in the right select box. This can be done for more than one employee. When I click the submit button, I want it to pass the value ...

  1. #1

    Default OT--capturing data from select

    Background:

    Intranet app written in ASP. I can't show you a URL, but I'll be glad to
    post snippets of code.

    I have two select boxes, and the one on the left has been populated from the
    database with the names of employees. The one on the right is empty when the
    page loads, but when you select a name on the left, and click the right
    arrow button, it places the name in the right select box. This can be done
    for more than one employee.

    When I click the submit button, I want it to pass the value of the name(s)
    in the right box, that is, the names which were selected, to the next page.
    However, it is passing an empty string. But if I were to actually select,
    that is, highlight with my mouse, the names on the right, then those values
    would in fact get passed. However, i can't ask users to click those names;
    that would be counter-intuitive big time.

    Here's some relevant code:

    In the javascript in the <head> section, I have

    var intIndex
    intIndex = frm.SelectedEmp.length
    frm.SelectedEmp.options[intIndex] = new Option(strTheEmp, strTheEmpID)
    frm.SelectedEmp.options[intIndex].selected = TRUE

    I should explain:
    The first line declares a variable.
    The 2nd line passes the value and the display part from the left box to the
    right
    <option value="100">Joe Smith</option>, where 100 is the employee ID, and
    the thing that I will want to be passed to the next page.
    And finally, the last line makes it work if I manually click on the name(s)
    in the right box.

    So I guess what I am saying is that there is probably a word other than
    "selected" for that last line which will grab the values of all items in
    that box, even though they aren't selected. But I don't know what that word
    is.







    middletree Guest

  2. #2

    Default Re: OT--capturing data from select

    Unless something is selected then there is nothing to pass, so you are going
    to have to select something. You say that making the person doing it will be
    counter productive. Is this because it is their records. Assuming that they
    have logged in why not grab something from this action and use it to make a
    selection for them.

    --
    Regards

    Paul Whitham
    Valleybiz Internet Design
    www.valleybiz.net

    Team Macromedia Volunteer for Ultradev/Dreamweaver MX
    www.macromedia.com/support/forums/team_macromedia
    "middletree" <com> wrote in message
    news:bgp89j$lof$macromedia.com... 
    the 
    the 
    done 
    page. 
    values 
    the 
    name(s) 
    word 


    Paul Guest

  3. #3

    Default Re: OT--capturing data from select

    I don't think I made myself clear.

    Counter-intuitive is not the same as counterproductive. I don't think it
    would be intuitive for someone to select Joe Smith's name from the left box,
    then click the right arrow, see it appear in the right box, and ask them to
    click that name again. The fact that it is in the right box means that they
    will assume it has been selected, since they, to their mind, selected that
    name already by just putting that name there.


    "Paul Whitham TMM" <net> wrote in message
    news:bgp9am$na7$macromedia.com... 
    going 
    be 
    they 

    > the 
    > the 
    > done [/ref]
    name(s) 
    > page. [/ref]
    select, 
    > values [/ref]
    names; 
    > the [/ref]
    and 
    > name(s) 
    > word 
    >
    >[/ref]


    middletree Guest

  4. #4

    Default Re: OT--capturing data from select

    When you submit the form, place an onclick command that selects all users to
    the submit button:

    onclick="selectAllOptions(doent.NameOfForm.Name Of2ndSelect)"


    And here is the js function:


    // -------------------------------------------------------------------
    // selectAllOptions(select_object)
    // This function takes a select box and selects all options (in a
    // multiple select object). This is used when passing values between
    // two select boxes. Select all options in the right box before
    // submitting the form so the values will be sent to the server.
    // -------------------------------------------------------------------
    function selectAllOptions(obj) {
    var iMax = 500;
    var iMaxCounter = obj.options.length;
    if (iMaxCounter > iMax) {
    iMaxCounter = iMax;
    }

    for (var i=0; i<iMaxCounter; i++) {
    obj.options[i].selected = true;
    }
    }


    Of note:
    // ================================================== =================
    // Author: Matt Kruse <com>
    // WWW: http://www.mattkruse.com/
    //
    // NOTICE: You may use this code for any purpose, commercial or
    // private, without any further permission from the author. You may
    // remove this notice from your final code if you wish, however it is
    // appreciated by the author if at least my web site address is kept.
    //
    // You may *NOT* re-distribute this code in any way except through its
    // use. That means, you can include it in your product, or your web
    // site, or any other form where the code is actually being used. You
    // may not put the plain javascript up on your site for download or
    // include it in your javascript libraries for download. Instead,
    // please just point to my URL to ensure the most up-to-date versions
    // of the files. Thanks.
    // ================================================== =================
    --

    __o
    _-\<,
    (_)/(_)____ http://tinyurl.com/2gf2
    ::kindler chase::

    wanna play? http://tinyurl.com/2gf0
    wanna cube? http://www.nCubed.com

    "When you find your passion, it's easy to be illogical" - me
    _______________________________________________

    Dreamweaver FAQ & Resource List
    http://www.dreamweaverfaq.com

    "middletree" <com> wrote in message
    news:bgp89j$lof$macromedia.com... 
    the 
    the 
    done 
    page. 
    values 
    the 
    name(s) 
    word 


    Kindler Guest

  5. #5

    Default Re: OT--capturing data from select

    This looks like what I need! Can't wait to try it tomorrow morning!

    thanks!


    "Kindler Chase" <com> wrote in message
    news:bgpgrp$4e0$macromedia.com... 
    to 
    > the 
    > the 
    > done [/ref]
    name(s) 
    > page. [/ref]
    select, 
    > values [/ref]
    names; 
    > the [/ref]
    and 
    > name(s) 
    > word 
    >
    >[/ref]


    middletree Guest

  6. #6

    Default Re: OT--capturing data from select

    You need some more javascript.

    <form action="" method="get" name="f">
    <input name="t" type="text" />
    <select name="g">
    <option value="r">red</option>
    <option value="w">white</option>
    <option value="b">blue</option>
    </select>
    </form>
    <script language="JavaScript" type="text/JavaScript">
    function getSelectItems(list) {
    b=new Array()
    for(a=0;a<list.length;a++){
    b[a]=list[a].value+"&"+list[a].text;
    }
    return b
    }
    doent.f.t.value=getSelectItems(doent.f.g)
    </script>
    Mick

    middletree wrote:
     
    mick_white Guest

  7. #7

    Default Re: OT--capturing data from select

    Will it change anything that I am not using the get method, but the post
    method?


    "mick_white" <com> wrote in message
    news:com... [/ref]
    the [/ref]
    the [/ref]
    done [/ref]
    name(s) [/ref]
    page. [/ref]
    select, [/ref]
    values [/ref]
    names; [/ref]
    the [/ref]
    and [/ref]
    name(s) [/ref]
    word [/ref]


    middletree Guest

  8. #8

    Default Re: OT--capturing data from select

    Didn't work. The only thing I changed from your code is I accounted for the
    difference in name of the form, and your text box that you named "t", I made
    it a hidden field, located after the select box, but before the </form> tag.
    On the submit image button, I included an onclick event to call
    getSelectedItems().


    "mick_white" <com> wrote in message
    news:com... [/ref]
    the [/ref]
    the [/ref]
    done [/ref]
    name(s) [/ref]
    page. [/ref]
    select, [/ref]
    values [/ref]
    names; [/ref]
    the [/ref]
    and [/ref]
    name(s) [/ref]
    word [/ref]


    middletree Guest

  9. #9

    Default Re: OT--capturing data from select

    If you use the "get" method, use a different separator:
    b[a]=list[a].value+":"+list[a].text;
    And include the print statement in the function.

    function getSelectItems(list) {
    b=new Array();
    for(a=0;a<list.length;a++){
    b[a]=list[a].value+":"+list[a].text;
    }
    doent.f.t.value=b;
    return b;
    }

    < form onsubmit="getSelectItems(g)">

    On your action page, you will see in the location after the "?"
    ?t=r:red,w:white,b:blue&g=r&Submit=Submit

    http://www.mickweb.com/javascript/forms/jumpmenus/getSelect/a.html

    Mick

    middletree wrote:
     [/ref]
    > the [/ref]
    > the [/ref]
    > done [/ref]
    > name(s) [/ref]
    > page. [/ref]
    > select, [/ref]
    > values [/ref]
    > names; [/ref]
    > the [/ref]
    > and [/ref]
    > name(s) [/ref]
    > word [/ref][/ref]

    mick_white Guest

  10. #10

    Default Re: OT--capturing data from select

    I'm using post. Have to.


    "mick_white" <com> wrote in message
    news:com... [/ref]
    the [/ref]
    made [/ref]
    tag. [/ref][/ref]
    glad to [/ref][/ref]
    from [/ref][/ref]
    when [/ref][/ref]
    right [/ref][/ref]
    be 
    > > name(s) [/ref][/ref]
    next 
    > > select, 
    > > values 
    > > names; [/ref][/ref]
    strTheEmpID) [/ref][/ref]
    to [/ref][/ref]
    ID, 
    > > name(s) [/ref][/ref]
    than [/ref][/ref]
    items in [/ref][/ref]
    that [/ref]
    >[/ref]


    middletree Guest

  11. #11

    Default Re: OT--capturing data from select

    What serverside language are you using?
    Mick

    middletree wrote:
     [/ref]
    > the [/ref]
    > made [/ref]
    > tag. [/ref]
    > glad to [/ref]
    > from [/ref]
    > when [/ref]
    > right [/ref]
    > be [/ref]
    > next [/ref]
    > strTheEmpID) [/ref]
    > to [/ref]
    > ID, [/ref]
    > than [/ref]
    > items in [/ref]
    > that 
    > >[/ref][/ref]

    mick_white Guest

  12. #12

    Default Re: OT--capturing data from select

    ASP.

    Want my code?


    "mick_white" <com> wrote in message
    news:com... [/ref][/ref]
    for [/ref][/ref]
    "t", I [/ref][/ref]
    </form> 
    > > glad to [/ref][/ref]
    populated [/ref][/ref]
    empty [/ref][/ref]
    the [/ref][/ref]
    can [/ref][/ref]
    the 
    > > next [/ref][/ref]
    actually [/ref][/ref]
    those [/ref][/ref]
    those 
    > > strTheEmpID) [/ref][/ref]
    box [/ref][/ref]
    employee [/ref][/ref]
    the [/ref][/ref]
    other 
    > > items in [/ref][/ref]
    what [/ref]
    >[/ref]


    middletree Guest

  13. #13

    Default Re: OT--capturing data from select

    I don't think that the fact that I'm using ASP is the issue. The page is not
    passing values from one page to the next, for this field only. It is passing
    them from the other fields in the form. In fact, it will pass values from
    this field if I manually select them. However, I am trying to find a way to
    make it pass the value of all options in that field without asking the user
    to manually click them. (kinda defeats the purpose, since they already
    clicked those names to get them into the box in the first place).

    This is the code which places the stuff from the left box over to the right
    one, when I clickthe right arrow button:

    var intIndex
    intIndex = frm.SelectedEmp.length
    frm.SelectedEmp.options[intIndex] = new Option(strTheEmp, strTheEmpID)
    frm.SelectedEmp.options[intIndex].selected = true


    It is that last line that should work. Perhaps I am placing it in the wrong
    place?


    "mick_white" <com> wrote in message
    news:com... [/ref][/ref]
    for [/ref][/ref]
    "t", I [/ref][/ref]
    </form> 
    > > glad to [/ref][/ref]
    populated [/ref][/ref]
    empty [/ref][/ref]
    the [/ref][/ref]
    can [/ref][/ref]
    the 
    > > next [/ref][/ref]
    ly [/ref][/ref]
    those [/ref][/ref]
    those 
    > > strTheEmpID) [/ref][/ref]
    box [/ref][/ref]
    employee [/ref][/ref]
    the [/ref][/ref]
    other 
    > > items in [/ref][/ref]
    what [/ref]
    >[/ref]


    middletree Guest

  14. #14

    Default Re: OT--capturing data from select

    Well, thanks for your help. I got it.

    What I did was I took this line out of a function and put it into my
    validation script, right above the "return true;"

    frm.SelectedEmp.options[intIndex].selected = true


    Thanks very much for your help on this.

    James W



    "mick_white" <com> wrote in message
    news:com... [/ref][/ref]
    for [/ref][/ref]
    "t", I [/ref][/ref]
    </form> 
    > > glad to [/ref][/ref]
    populated [/ref][/ref]
    empty [/ref][/ref]
    the [/ref][/ref]
    can [/ref][/ref]
    the 
    > > next [/ref][/ref]
    actually [/ref][/ref]
    those [/ref][/ref]
    those 
    > > strTheEmpID) [/ref][/ref]
    box [/ref][/ref]
    employee [/ref][/ref]
    the [/ref][/ref]
    other 
    > > items in [/ref][/ref]
    what [/ref]
    >[/ref]


    middletree Guest

Similar Threads

  1. capturing scrolling data in fillable pdf
    By beachlover@adobeforums.com in forum Adobe Acrobat Macintosh
    Replies: 3
    Last Post: January 23rd, 11:09 PM
  2. Capturing Debugging Data
    By Sarah DeShazo in forum Coldfusion - Advanced Techniques
    Replies: 4
    Last Post: April 28th, 07:21 AM
  3. Capturing data from page and displying it in another
    By xantia7 in forum Macromedia ColdFusion
    Replies: 2
    Last Post: March 12th, 06:47 PM
  4. capturing streaming market data
    By Mark S. Warren in forum PERL Miscellaneous
    Replies: 0
    Last Post: June 25th, 03:49 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139