SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member happysailingdude's Avatar
    Join Date
    Apr 2006
    Posts
    17
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question a.style.visibility='visible'; how to get this to work in firefox

    hi there - oddly i have something that works just fine in IE but it wont work in firefox

    when the page is loaded there is a form field and some text. the text is hidden. i want to make it so that when the form field is changed then the text becomes visible

    so i have the following:

    function changeit() {
    a.style.visibility='visible';
    }

    <input name="emailAddress" type="text" id="emailAddress" onChange="changeit();" />

    <div id="a" name="a" style="visibility:hidden ;">
    this text should appear when the user changes the form field above
    </div>


    in IE everything works as planned but in firefox it doesnt - the firefox javascript console tells me that "a is not defined"

    im still struggling to get to grips with javascript so if anyone could please help me i'd be very grateful indeed.

    thanks very much

  2. #2
    I meant that to happen silver trophybronze trophy Raffles's Avatar
    Join Date
    Sep 2005
    Location
    Tanzania
    Posts
    4,662
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    a is assumed to be a variable and you haven't defined it. You can do this:
    Code:
    function changeit() {
    document.getElementById('a').style.visibility='visible';
    }
    or
    Code:
    var a = document.getElementById('a');
    function changeit() {
    a.style.visibility='visible';
    }

  3. #3
    SitePoint Member happysailingdude's Avatar
    Join Date
    Apr 2006
    Posts
    17
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Smile Solved!

    Thanks Raffles - that's great. and thank you for such a rapid reply

    much appreciated


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
  •