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??
| SitePoint Sponsor |
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??
In HTML:
then, in JS:Code:<div id="mydiv">(insert content here)</div>
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?Code:var div = document.getElementById("mydiv"); div.style.visibility="hidden"; // hide it // or div.style.visibility="visible"; // show it
The above will just make the div invisible. It will still occupy space on the page. To stop it taking up space, add:
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?Code:div.style.display="none"; // it's not there // or div.style.display="block"; // yes it is!
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.
when writing html into a div using java script should the following work?
when reffering to a DIV called in the BODY like this:text = 'blah de blah';
document.getElementById[theDiv].innerHTML = text;
I'm currently trying to get something like this to work and its not...<div id="theDiv"></div>
Am I doing anything obviously wrong?
That should beCode:<div id="theDiv">content</div> ... text = 'blah de blah'; 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.Code:document.getElementById("theDiv").innerHTML = text;
Of course, last time I looked, Opera couldn't cope with getElementById() at ALL, but that's Opera's problem.





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(what, text)
{
what.innerHTML = text;
}
</script>
Bookmarks