Results 1 to 11 of 11

Thread: [java script] different browsers

Hybrid View

  1. #1

    Thread Starter
    Hyperactive Member DaveR's Avatar
    Join Date
    Mar 2001
    Location
    Ireland
    Posts
    268

    [java script] different browsers

    Hi,

    I have the following code on an asp page and it works fine from a mozilla bowser but when run from internet explorer is doesnt seem to work at all.

    function Approach (theform) {
    var pregen = 0 ;
    pregen = theform.sel_app_1.value
    alert(pregen)
    return;
    }

    called from a select box as follows.
    onChange= "Approach(this.form) ;"

    With the mozilla browser it displays the selected value

    With internet explorer it just displays the default value of 0

    If any one has even the slightest idea of what the problem is here , please let me know.

    Thank
    DaveR

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    How are you getting that to run without semicolons in place?

  3. #3

    Thread Starter
    Hyperactive Member DaveR's Avatar
    Join Date
    Mar 2001
    Location
    Ireland
    Posts
    268
    There are semi colons on the code on the page, deleted them by accident on the post.
    DaveR

  4. #4
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359
    I've never used the this keyword in js before... I'd normally just use document.myform or something to that effect...
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

  5. #5

    Thread Starter
    Hyperactive Member DaveR's Avatar
    Join Date
    Mar 2001
    Location
    Ireland
    Posts
    268
    Even when I use the the actual form name in the function , ie. in effect ignoring the input parameter, it still gives me a value of 0 .
    DaveR

  6. #6
    Frenzied Member Acidic's Avatar
    Join Date
    Sep 2003
    Location
    UK
    Posts
    1,090
    Why not:
    Code:
    <textarea onchange="Approach(this)"></textarea>
    ...
    function Approach (_obj) {
    var pregen = 0 ;
    pregen = _obj.value
    alert(pregen)
    return;
    }
    Last edited by Acidic; Nov 19th, 2004 at 09:10 AM.
    Have I helped you? Please Rate my posts.

  7. #7

    Thread Starter
    Hyperactive Member DaveR's Avatar
    Join Date
    Mar 2001
    Location
    Ireland
    Posts
    268
    I am calling it from a drop down select box, eventually I want the function to do calculations on a few different drop down boxes on the form.

    Functions calls ok ,but it just cant read the selected value of the dropdown box.
    DaveR

  8. #8
    Frenzied Member Acidic's Avatar
    Join Date
    Sep 2003
    Location
    UK
    Posts
    1,090
    Code:
    <select onchange="Approach(this.value)">
        <option value="abc">abc</option>
        ...
    </select>
    Have I helped you? Please Rate my posts.

  9. #9

    Thread Starter
    Hyperactive Member DaveR's Avatar
    Join Date
    Mar 2001
    Location
    Ireland
    Posts
    268
    Its in the function the problem is:

    function Approach (theform) {
    var pregen = 0 ;
    pregen = theform.sel_app_1.value; alert(pregen);
    return;
    }

    theform.sel_app_1.value gives me a value of 0 no matter what I select.
    Works fine in mozilla.
    DaveR

  10. #10
    Frenzied Member Jop's Avatar
    Join Date
    Mar 2000
    Location
    Amsterdam, the Netherlands
    Posts
    1,986
    It's a faulty implementation on IE's side:

    http://www.shaftek.org/blog/archives/000153.html
    Jop - validweb.nl

    Alcohol doesn't solve any problems, but then again, neither does milk.

  11. #11
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    A good reason always to use the value attribute.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

Posting Permissions

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



Click Here to Expand Forum to Full Width