Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 15 of 15
  1. #1
    Regular Coder
    Join Date
    Jul 2003
    Location
    NJ - #29 if you must know
    Posts
    117
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Can the delimter returned in a <SELECT> list be changed?

    If you have a <SELECT with MULTIPLE selects, what is
    returned on posting is delimited (separated) by comma & space.

    Is there anyway to change this delimiter? I know in perl
    you can change the delimter of an array. Right now this
    isn't an issue, since none of my .values have commas in
    them, but if they did, I wouldn't be able to tell which
    comma belonged and which did not. I did an IE test,
    and it did NOT quote any fields with the delimiter in them.

    For now, I have a routine that goes through and changes
    anys commas to a predefined character. But I'd rather not
    waste time scanning select lists.

    An example: If I had a select list with "1" "2" & "3" selected
    what is returned is: 1, 2, 3
    If the select list were "1,2" "4,5" & "8,9" what would be
    returned would be: 1,2, 4,5, 8,9

    If I were trying to parse this list based on commas, It would
    be almost impossible to get the correct data.

    Thanks
    George

  • #2
    Senior Coder joh6nn's Avatar
    Join Date
    Jun 2002
    Location
    72° W. 48' 57" , 41° N. 32' 04"
    Posts
    1,887
    Thanks
    0
    Thanked 1 Time in 1 Post
    i'm thinking this isn't possible. sorry.
    bluemood | devedge | devmo | MS Dev Library | WebMonkey | the Guide

    i am a loser geek, crazy with an evil streak,
    yes i do believe there is a violent thing inside of me.

  • #3
    Senior Coder
    Join Date
    Aug 2002
    Posts
    3,467
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You are talking about what the server actually receives, yes? I agree w/joh6nn, no way to change that.

    You could, however, use JS to populate a hidden input with the selected values delimited by a character of your choosing, onsubmit of the form. A bit hacky, but it could work.
    My Site | fValidate | My Brainbench | MSDN | Gecko | xBrowser DOM | PHP | Ars | PVP
    “Minds are like parachutes. They don't work unless they are open”
    “Maturity is simply knowing when to not be immature”

  • #4
    Regular Coder
    Join Date
    Jul 2003
    Location
    NJ - #29 if you must know
    Posts
    117
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I'd rather change the actual data to a non-used character
    like my routine does now, one less field to send back

    That's one of the big differences between WORD and
    EXCEL when you save a comma delimited file.
    WORD just sticks comma between them,
    EXCEL on the other hand looks at the data, if there
    is a comma, it then quotes the field.

    Maybe on the next javascript version, it will quote the
    fields.

    Thanks, just checking to see if anyone had any way
    of actually changing the delimiter vs changing the
    data, although creating the hidden field isn't a
    bad way either, since it wouldn't require anything
    server side to convert the non used character back
    to comma's.

    George

  • #5
    Senior Coder
    Join Date
    Jun 2002
    Location
    frankfurt, german banana republic
    Posts
    1,848
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I don't know what serverside language you use, but in PHP, if you name the multiple select list like test[] it indicates to the receiving PHP script that the values shall be put in an array - and there's no problem with commas within the option values, all comes neatly out in separate array elements. Absolutely no hassle with that.
    De gustibus non est disputandum.

  • #6
    Regular Coder
    Join Date
    Jul 2003
    Location
    NJ - #29 if you must know
    Posts
    117
    Thanks
    0
    Thanked 0 Times in 0 Posts
    It's a perl .cgi that receives the posted data.

    Does the browser behave differently if the program
    recieiving isn't a .cgi. I thought a post was a post.

    the delimiter appears to be ", " comma space.
    I dont work in PHP so I can't test it. Be intrested
    to see if it works with a comma-space in the
    data however.

    George

  • #7
    Senior Coder
    Join Date
    Jun 2002
    Location
    frankfurt, german banana republic
    Posts
    1,848
    Thanks
    0
    Thanked 0 Times in 0 Posts
    How do you have your select list named? I just toyed a little with the list's name, and guess what, the [] brackets apparently force the user agent to send a slightly different HTTP post content. With the brackets, a url-encoded list of all selected values from the last are sent, without the brackets, only one value appears.

    Surely you can access raw POST data in Perl, and from this data reconstruct your single comma-infested values? I don't know Perl enough so I can't help you on that topic, but maybe the people in the CGI/Perl forum can.
    De gustibus non est disputandum.

  • #8
    Regular Coder
    Join Date
    Jul 2003
    Location
    NJ - #29 if you must know
    Posts
    117
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I must be missing something here...

    What do you mean by []'s in the name?

    My HTML is setup:

    <SELECT NAME="SOMETHING" MULTIPLE=MULTIPLE SIZE=3>
    </SELECT>

    Then I use Javscript to add new values/codes to the Select
    list, and prior to submitting the form, I have a function that
    goes through and sets the select on each of the elements.

    What does your raw data look like?

    George

  • #9
    Senior Coder
    Join Date
    Jun 2002
    Location
    frankfurt, german banana republic
    Posts
    1,848
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I meant it like this:

    <SELECT NAME="SOMETHING[]" MULTIPLE=MULTIPLE SIZE=3>

    and the raw post data that gets sent (verified it with Mozillas LiveHTTPHeaders utility) was:

    test%5B%5D=5%2C6&test%5B%5D=7%2C8

    which decodes, by help of PHPs builtin rawurldecode() function, into:

    test[]=5,6&test[]=7,8

    and this string is later transformed into an array by PHP - you see, no confusion due to commas.
    De gustibus non est disputandum.

  • #10
    Regular Coder
    Join Date
    Jul 2003
    Location
    NJ - #29 if you must know
    Posts
    117
    Thanks
    0
    Thanked 0 Times in 0 Posts
    HUH? I never heard of putting []'s into the name for
    any reason before. I'll have to see what happens.

    Thanks
    George

  • #11
    Regular Coder
    Join Date
    Jul 2003
    Location
    NJ - #29 if you must know
    Posts
    117
    Thanks
    0
    Thanked 0 Times in 0 Posts
    When I changed my NAME = "SALESTO[]"

    my javascript didn't work...

    So I changed my javascript to:

    makeallselected(document.FORM1.SALESTO[]);

    and that gave me an error

    George

  • #12
    Senior Coder
    Join Date
    Aug 2002
    Posts
    3,467
    Thanks
    0
    Thanked 0 Times in 0 Posts
    makeallselected(document.FORM1.elements['SALESTO[]']);
    My Site | fValidate | My Brainbench | MSDN | Gecko | xBrowser DOM | PHP | Ars | PVP
    “Minds are like parachutes. They don't work unless they are open”
    “Maturity is simply knowing when to not be immature”

  • #13
    Regular Coder
    Join Date
    Jul 2003
    Location
    NJ - #29 if you must know
    Posts
    117
    Thanks
    0
    Thanked 0 Times in 0 Posts
    OK. I see what it's doing.

    I had to look at the raw raw data, my perl program
    automagically converts the %## to their ASCII
    equiv's so it still looked like commas to me

    So it (browser) doesn't convert delimiting commas
    to %2C, but does convert commas within the data
    to %2C.

    That will work.

    Now I'll have to recheck my raw raw data again
    the original way and see if it did it that way as
    well.

    I forgot my .cgi did that little conversion for me, so
    it the comma always looked like a comma

    George

  • #14
    Senior Coder joh6nn's Avatar
    Join Date
    Jun 2002
    Location
    72° W. 48' 57" , 41° N. 32' 04"
    Posts
    1,887
    Thanks
    0
    Thanked 1 Time in 1 Post
    that was brilliant, Mordred. i would never have thought of that.
    bluemood | devedge | devmo | MS Dev Library | WebMonkey | the Guide

    i am a loser geek, crazy with an evil streak,
    yes i do believe there is a violent thing inside of me.

  • #15
    Senior Coder
    Join Date
    Jun 2002
    Location
    frankfurt, german banana republic
    Posts
    1,848
    Thanks
    0
    Thanked 0 Times in 0 Posts
    joh6nn, I feel flattered.
    My curiosity was sparked because I recently developed a PHP script that processed a similar multiple select list and as I said, it worked out of the box. So ggallens problem struck me as weird. Honestly, I didn't know that the brackets were the decisive key to this riddle, I just found out by watching the communication between Mozilla and a little PHP test script.

    For whom it may concern, to debug cases like this the plugin LiveHTTPHeaders is a real life-saver. It's pretty to install too. I recommend it very much.
    De gustibus non est disputandum.


  •  

    Posting Permissions

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