| PHP, MySQL General PHP questions. Or go to our PHPsuexec Forum >> |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread |
|
|
#1 (permalink) |
|
I own you!
Excelling Contributor
Joined in Apr 2004
563 posts
Gave thanks: 0
Thanked 3 times
|
Collapsing
Hello,
I don't know if that is done with PHP or JavaScript, so I am posting it here (Mods, move this to the correct forums otherwise). Basically, I have multiple forms on 1 page. What I want to do, is have displayed only links, and when users click on one of the links, the form will show up. If clicked once again, it will hide. Of course I also want the link name to change appropriately to something from "Link 1 >>" to "Link 1 <<." Much like vBulletin does on the main page of the forums. My question is: how do you do it? Thanks again, |
|
|
|
|
|
#2 (permalink) |
|
after g, before i
Resident.
Joined in Jul 2004
Lives in N,BC,CA
8,086 posts
Gave thanks: 48
Thanked 131 times
|
Well, you could accomplish it with either PHP or JavaScript. Basically you have to determine:
a) do I want it to occur regardless of whether JavaScript is enabled? b) do I want it to happen instantaneously or have a refresh? If you answered yes to a, then you're going with PHP. If you answered yes to question b, you're going with JavaScript. As far as I know vBulletin uses JavaScript, because I'm positive it's done instantaneously. I'll have to confirm some code and eat some breakfast, then I'll post a possible solution for JavaScript. |
|
|
|
|
|
#3 (permalink) |
|
Surpass Fan
Super #1
Joined in Aug 2004
Hosted on SH58
1,688 posts
Gave thanks: 6
Thanked 7 times
|
I do this on a lot of my sites. I write a small universal function call showHide() and it goes like this...
Code:
function showHide( objID ){
var obj = document.getElementById( objID );
var status = obj.style.display;
if( status == 'block' ){
obj.style.display = 'none';
} else{
obj.style.display = 'block';
}
}
Hope that helps!
__________________
- Evan Charlton | [site] | Server - SH58 |
|
|
|
|
|
#4 (permalink) |
|
after g, before i
Resident.
Joined in Jul 2004
Lives in N,BC,CA
8,086 posts
Gave thanks: 48
Thanked 131 times
|
Alright, here's my example code: http://haugland.ca/toggle/
Basically what you do is add this to your head: Code:
<script type="text/javascript">
function showorhide(id) {
if (document.getElementById(id).style.display == "none") {
document.getElementById(id).style.display = "block";
} else {
document.getElementById(id).style.display = "none";
}
}
</script>
Code:
<a href="#" onclick="showorhide('raw');" />Toggle</a><br /><br />
<div id="raw">This is a bunch of text yo... and more text because<br />
We want a lot of the text.</div>
The <div> tag: I used a div tag because I felt like it... You could replace it with a table, image, list or whatever your heart desires, and also put whatever the hell you want in it. So basically the only thing you do with this element is give it an ID (which has to be UNIQUE), so that the JavaScript can discover the element. If you need anymore help, just post again with what you're needing help with. |
|
|
|
|
|
#7 (permalink) |
|
Surpass Fan
Super #1
Joined in Aug 2004
Hosted on SH58
1,688 posts
Gave thanks: 6
Thanked 7 times
|
That's kinda creepy...are you stealing the source from my sites? or stalking me?
Either way I'm flattered.
__________________
- Evan Charlton | [site] | Server - SH58 |
|
|
|
|
|
#8 (permalink) |
|
after g, before i
Resident.
Joined in Jul 2004
Lives in N,BC,CA
8,086 posts
Gave thanks: 48
Thanked 131 times
|
Pfft... We both know I took a JavaScript class last year... It was actually from memory from something I did over a year ago. Neat little function it is.
|
|
|
|