Hello there!
I've been attempting to create a toggle effect using an anchor link with an "onclick" event to show and hide content. Despite my efforts with jQuery and JavaScript functions, I just can't seem to figure out the right approach. Here's what I have so far (my 8th attempt):
Here are the styles in styles.css:
.noPhones{
display: none;
}
The JavaScript code in contacts.tpl:
{literal}
<script type="text/javascript">
function swapMyToggledDiv()
{
if(document.getElementById(".noPhones").style.display == "none")
{
document.getElementById(".noPhones").style.display = "block";
}
else
{
document.getElementById(".noPhones").style.display = "none";
}</script>
{/literal}
And finally, here's how the forms are structured in contacts.tpl:
<tr><td>
<h2><a href="#" onclick="swapMyToggledDiv()">Phone</a></h2>
</td><td>
// form inputs here
</td></tr>
// additional form input rows with class "noPhones", initially hidden
I am looking to have all the rows with the "noPhones" class hidden until the user clicks on the anchor link. Any assistance or guidance on this matter would be truly appreciated!
Thank you in advance for any help!