SitePoint Sponsor

User Tag List

Page 2 of 2 FirstFirst 12
Results 26 to 43 of 43
  1. #26
    Perl/Mason Guru Flawless_koder's Avatar
    Join Date
    Feb 2002
    Location
    Gatwick, UK
    Posts
    1,206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hang on - i'll test something on a server here and get back
    to you in a few mins.

    Flawless
    ---=| If you're going to buy a pet - get a Shetland Giraffe |=---

  2. #27
    Perl/Mason Guru Flawless_koder's Avatar
    Join Date
    Feb 2002
    Location
    Gatwick, UK
    Posts
    1,206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    change the top one to:

    alert('Index: '+initiallySelectedOne.selectedIndex);


    This seems strange, because this works:

    http://www.passway.org/op.html

    Flawless
    ---=| If you're going to buy a pet - get a Shetland Giraffe |=---

  3. #28
    Perl/Mason Guru Flawless_koder's Avatar
    Join Date
    Feb 2002
    Location
    Gatwick, UK
    Posts
    1,206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Found the problem.

    name isn't a parameter recognised for the Option element
    by netscape aparently.

    If you tell it to alert the name - it won't.

    If you tell it to alert the className - it does.

    However in my test - it does alert the selected index.

    which means your one is acting strangely...

    Flawless
    ---=| If you're going to buy a pet - get a Shetland Giraffe |=---

  4. #29
    ********* Ornithologist AtomicPenguin's Avatar
    Join Date
    May 2002
    Location
    Vancouver, BC
    Posts
    459
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I tried that link on each browser. Both drew the <select> box, but alerted different things (Explorer: [object], Netscape: undefined)

    What do you think is going on?

  5. #30
    ********* Ornithologist AtomicPenguin's Avatar
    Join Date
    May 2002
    Location
    Vancouver, BC
    Posts
    459
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Erg. This is heavy stuff; I'm going to have to take a raincheck. Here it's 5 in the morning and the birds have just started to chirp. I think bed might be in order...!

    I really can't thank you enough for your help! What I'll do is sleep on it, then look it over tomorrow. If you're around tomorrow night, I'll probably end up bugging you again. ;-)

    Again, thanks VERY much!

  6. #31
    Perl/Mason Guru Flawless_koder's Avatar
    Join Date
    Feb 2002
    Location
    Gatwick, UK
    Posts
    1,206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'll work on it while you sleep.

    It's confuzzlin' the hell outta me - it's gotta be something
    simple!

    Flawless
    ---=| If you're going to buy a pet - get a Shetland Giraffe |=---

  7. #32
    SitePoint Enthusiast
    Join Date
    Apr 2002
    Posts
    75
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Atomic,

    It sounds like what you're looking for is the 'text' property.

    Is this what you're trying to do?

    <script>
    function doThis(){
    chosenOne = document.forms[0].city;
    city = chosenOne.options[chosenOne.selectedIndex].text;
    alert(city);
    }
    </script>
    <form>
    <select name="city" onchange="doThis()">
    <option value="a">London</option>
    <option value="b">New York</option>
    <option value="c">Munich</option>
    </select>
    </form>

  8. #33
    Perl/Mason Guru Flawless_koder's Avatar
    Join Date
    Feb 2002
    Location
    Gatwick, UK
    Posts
    1,206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That's not the problem.

    Netscape doesn't seem to acknowledge the selectedIndex.

    You could see that if you looked at:

    This is interesting. On Explorer, we got: 13, [Object], Surrey. But Netscape didn't do diddly squat. I tried refreshing countless times & emptying the cache, but I got no alerts...
    So it's got nothing to do with what property you're looking at ( yet - though it will later since the name property isn't valid in nescape ), since the object isn't even being
    referenced!

    Flawless
    ---=| If you're going to buy a pet - get a Shetland Giraffe |=---

  9. #34
    SitePoint Enthusiast
    Join Date
    Apr 2002
    Posts
    75
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well, I've tested my little snippet of code there on Netscape 4.75 and Netscape 6 and it works on both, so perhaps there's some other version I haven't tested it on that doesn't work.

    And it's not Netscape that has a problem with the name property. 'name' is not a property of the option element but of the select element.
    [ http://www.w3.org/TR/REC-DOM-Level-1...l#ID-798055546 ]

  10. #35
    Perl/Mason Guru Flawless_koder's Avatar
    Join Date
    Feb 2002
    Location
    Gatwick, UK
    Posts
    1,206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    There is nothing new about ie going above and beyond w3c specs.

    My comment was quite valid:
    the name property ISN'T valid in netscape!

    AND yes - you're little snippet might have worked fine for you, but it's not YOUR page that's the problem - is it?

    For some reason the page that Atomic is using has deconstructed the hierarchy so that the object properties don't seem to be returning properly.

    Flawless
    ---=| If you're going to buy a pet - get a Shetland Giraffe |=---

  11. #36
    SitePoint Enthusiast
    Join Date
    Apr 2002
    Posts
    75
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hmm, I guess I missed the point. I thought the main goal was to find a way to get BOTH IE and Netscape to return the text between the option tags.

    Yes, Atomic's code is the issue here not my snippet but if you apply the technique to his code you can get return most properties on both browsers, including className.

    Really, I've never seen anyone get so worked up over a simple offer to help.

    Since this is Atomic's problem, maybe we could hear a little bit from him on the matter.

  12. #37
    Perl/Mason Guru Flawless_koder's Avatar
    Join Date
    Feb 2002
    Location
    Gatwick, UK
    Posts
    1,206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm not worked up - silly
    You can never read emotions through a font - so don't try - it leads to confusion.

    .oO( otherwise i'd have thought you were trying it on with me from the way you typed that Hmmm )

    http://www.passway.org/opR.html

    That's a copy of the page.

    i don't have too much time to play with it right now,
    if you have any ideas - post them and i'll change the code.

    * time to play - spot the leak *

    Flawless
    ---=| If you're going to buy a pet - get a Shetland Giraffe |=---

  13. #38
    SitePoint Enthusiast
    Join Date
    Apr 2002
    Posts
    75
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This works.

    <form name="cat" id="cat">
    <select id="city" name="city" onchange="update_area(this);">
    <option value="Anmore" class="cities">Anmore</option>
    <option value="Belcarra" class="cities">Belcarra</option>
    <option value="Burnaby" class="cities" SELECTED=true>Burnaby</option>
    </select> </form>
    <script language="Javascript">
    t=document.forms[0].city;
    alert(t.options[t.selectedIndex].className); // this will work with Netscape 6+
    alert(t.options[t.selectedIndex].value); // this will work with ie, Netscape 4.75 and Netscape 6
    </script>

    You will have less cross-browser trouble if you write the tags the way they were intended to be written: using 'value' in the option tag, not name.

    In your link below, there appears to be several problems -
    I'm getting a syntax error in city_area_list.js. I can't access the file so I can't see the problem.

    location_array is not defined in the page; maybe it's in the script but then the syntax error is causing it to bomb.

  14. #39
    Perl/Mason Guru Flawless_koder's Avatar
    Join Date
    Feb 2002
    Location
    Gatwick, UK
    Posts
    1,206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The names have been changed to values.

    Flawless
    ---=| If you're going to buy a pet - get a Shetland Giraffe |=---

  15. #40
    SitePoint Enthusiast
    Join Date
    Apr 2002
    Posts
    75
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hello? AtomicPenguin? Are you still there?

  16. #41
    ********* Ornithologist AtomicPenguin's Avatar
    Join Date
    May 2002
    Location
    Vancouver, BC
    Posts
    459
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sorry for my long absence, I've been stricken with a visit from my brother... and we're scooting off out of town tomorrow, so don't be offended if I don't reply too quickly over the next couple of days.

    -------

    Thanks so much for your help. I'm going look over that snippet of code you gave, Shoop, and see if I can get it to go.


    Couple of questions:

    - Is using 'value' instead of 'name' the right way to do it? I've never heard that. And why is that? I've always just figured that you could do the same thing with either, so just, hey! pick one you like!

    - Out of curiosity, why is it 'good etiquette' or 'good form' to set both id and name to be the same? I've heard that said a few times & I've never quite followed why.


    And again - thanks so much for your help. Once I mull over the code, I'll get back to you (hopefully tonight).

  17. #42
    ********* Ornithologist AtomicPenguin's Avatar
    Join Date
    May 2002
    Location
    Vancouver, BC
    Posts
    459
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Getting there...

    Excellent! It works... a bit better :-) But there's still a couple of problems.

    1: why doesn't Netscape 6 run the initialize() function? Or if it does, why doesn't it alert() the city value?

    initSelectedOne = document.properties.city;
    city = initSelectedOne.options[initSelectedOne.selectedIndex].value;

    alert(city);

    2: When I refresh the page with Netscape, the area field empties.

    [look at the URL I've sent to you privately]


    By the way, I'm only really concerned with getting this page working for the newest browsers (ie6, netscape6) , since it'll be for administrators only. I can thus insist on them having a newish browser (but no complaints if it works across the board!)

  18. #43
    Perl/Mason Guru Flawless_koder's Avatar
    Join Date
    Feb 2002
    Location
    Gatwick, UK
    Posts
    1,206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes - you should use the value property - not the name unless you're doing it very intentionally for some reason.

    Netscape IS running the initialize function - but it doesn't
    accept city as an object parameter - that's the whole
    problem that we're discussing really.

    Flawless
    ---=| If you're going to buy a pet - get a Shetland Giraffe |=---


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
  •