SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Enthusiast
    Join Date
    Jun 2002
    Posts
    43
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    NS 6 and POST help

    okay, 2 questions

    how do you change the visibility of a DIV in NS6 using JS and...

    I need to get the variables from a POST and I can't remember the code needed.

    can ne 1 please help me??

  2. #2
    SitePoint Guru bronze trophy blufive's Avatar
    Join Date
    Mar 2002
    Location
    Manchester, UK
    Posts
    853
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    In HTML:
    Code:
    <div id="mydiv">(insert content here)</div>
    then, in JS:
    Code:
    var div = document.getElementById("mydiv");
    div.style.visibility="hidden"; // hide it
    // or
    div.style.visibility="visible"; // show it
    This code should also work in at IE5.5 upwards on PC and IE5 upwards on Mac. Might even work in IE5 PC too. Aren't standards wonderful?

    The above will just make the div invisible. It will still occupy space on the page. To stop it taking up space, add:
    Code:
    div.style.display="none"; // 
    it's not there
    // or
    div.style.display="block"; // yes it is!
    Re: variables from a POST, I can't help. Anyone who can help, however, will want to know what method you're using: ASP? JSP? CGI? Trained Armadillos?

  3. #3
    SitePoint Enthusiast
    Join Date
    Jun 2002
    Posts
    43
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    cheers for that, just making it invisible was all I needed

    saying it was a POST might have been a bit hasty, its either POST or GET, I can't remember... but either way, its the one where the information appears in the url after a '?' in the form 'variable1=a&variable2=b' etc so I don't need to specify what method I'm using do i??? I would only need to do that if I was using the other method.. I think? i dunno.
    Last edited by Lunchy_Munchy; Jun 11, 2002 at 14:26.

  4. #4
    SitePoint Enthusiast
    Join Date
    Jun 2002
    Posts
    43
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    when writing html into a div using java script should the following work?

    text = 'blah de blah';
    document.getElementById[theDiv].innerHTML = text;
    when reffering to a DIV called in the BODY like this:

    <div id="theDiv"></div>
    I'm currently trying to get something like this to work and its not...
    Am I doing anything obviously wrong?

  5. #5
    SitePoint Guru bronze trophy blufive's Avatar
    Join Date
    Mar 2002
    Location
    Manchester, UK
    Posts
    853
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    <div id="theDiv">content</div>
    ...
    text = 'blah de blah';
    document.getElementById[theDiv].innerHTML = text;
    That should be

    Code:
    document.getElementById("theDiv").innerHTML = text;
    note the round brackets and quotes. Also, remember that innerHTML is non-standard and will only work in IE and Mozilla-based browsers: anything else will likely collapse in a messy heap.

    Of course, last time I looked, Opera couldn't cope with getElementById() at ALL, but that's Opera's problem.

  6. #6
    Currently Occupied; Till Sunda Andrew-J2000's Avatar
    Join Date
    Aug 2001
    Location
    London
    Posts
    2,475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you should try to avoid referencing the object at all besides 'this'.

    As it comply's with all browsers.

    PHP Code:
    <div onclick="blah(this)">blah</div>

    <
    script type="text/javascript">
      function 
    blah(whattext)
      {
        
    what.innerHTML text;
      }
    </script> 


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
  •