DIR Return Create A Forum - Home
---------------------------------------------------------
Create A Forum - Support Forums
HTML https://support.createaforum.com
---------------------------------------------------------
*****************************************************
DIR Return to: Create a Forum Codes and Support
*****************************************************
#Post#: 23698--------------------------------------------------
Javascript Function
DIR By: mickjav
Date: November 29, 2020, 5:52 am
---------------------------------------------------------
I want to add a function to my forum which I am thinking of
adding to my footer section
My problem is i wish to use this for a q/a page hiding and
showing answers useing the code below
--- Code ---
<button onclick="myFunction()">Click Me</button>
<div id="myDIV">
This is my DIV element.
</div>
--- End Code ---
[/color][/color]
--- Code ---
function myFunction() {
var x = document.getElementById("myDIV");
if (x.style.display === "none") {
x.style.display = "block";
} else {
x.style.display = "none";
}
}
--- End Code ---
[color=mediumblue][color=black]What I am thinking of doing but
not sure if it will work is alter the call and the
document.getElementById("myDIV");Like[/color]
--- Code ---
<button onclick="myFunction(dv1)">Click Me</button>
<div id="dv1">
This is my DIV element.
</div>
--- End Code ---
And update the function so:
--- Code ---
function myFunction(myDIV) {
var x = document.getElementById(myDIV);
if (x.style.display === "none") {
x.style.display = "block";
} else {
x.style.display = "none";
}
}
--- End Code ---
[color=brown]
Would this work?
#Post#: 23699--------------------------------------------------
Re: Javascript Function
DIR By: mickjav
Date: November 29, 2020, 6:43 am
---------------------------------------------------------
Got this workng with a few minor issues which I'm sure I can
sort
#Post#: 23700--------------------------------------------------
Re: Javascript Function
DIR By: CreateAForum
Date: November 29, 2020, 9:00 am
---------------------------------------------------------
Nice work!
#Post#: 23701--------------------------------------------------
Re: Javascript Function
DIR By: mickjav
Date: November 29, 2020, 9:23 am
---------------------------------------------------------
Just in case anybody else wants to do something like this you
can use the below
Add this function to your Footer section Style Manager->Headers
and footers
--- Code ---
<script type="text/javascript">
<!--
function toggle_visibility(id) {
var e = document.getElementById(id);
if(e.style.display == 'block')
e.style.display = 'none';
else
e.style.display = 'block';
}
//-->
</script>
--- End Code ---
Past this into a page to see it work
--- Code ---
<div class="cat_bar">
<h3 class="catbg centertext" style="text-align: left;"><span
style="font-size: small;" title="Click to view answer"
onclick="toggle_visibility('DD0')">What software do you use to
build database's
</span></h3>
</div>
<div id="DD0" style="display: none; text-align: left;">We use
Microsoft Access for all our database's, We have also worked
with mysql, PHP and Visual Basic</div>
--- End Code ---
P.S One thing I itend doing is making the click text look like a
link
*****************************************************
Page 1 of 1