|
|
#1 |
|
Member
Join Date: Dec 2006
Posts: 96
Rep Power: 12 ![]() |
Hi
I am trying to write a javascript that shows and hides text. Take a look at http://www.landsnett.no/modules.php?mod=checkout and click on the second questionmark from the top. As you can see the text appears. The thing is that I must click on the same questionmark to hide the text. What I would like to do is to hide the text when clicking on any other of the questionmark images, plus that the text belonging to the questionmark clicked appears. I have tried to do this using the following script: Code:
<script language="JavaScript">
{literal}
<!--//
function GetInfo(container)
{
var show = document.getElementById('container' + container);
show.style.display = "block";//show selected info
var containers = new Array();//initialize array
{/literal}
{foreach from=$cat_data item=item}
containers.push({$item.id});//add each to the end of array
{/foreach}
{literal}
for (var i=0; i<containers.length; i++) { //loop through array and hide all but show
var idContainer = 'container' + containers[i];
if (idContainer != container) {
document.getElementById(idContainer).style.display = "none";
}
}
}
//-->
{/literal}
HTML Code:
{html_table_adv loop=$cat_data cols=$cols table_attr='width="100%"'}
<a id="moreLink" href="#" onClick="GetInfo('container[[id]]');">
<img src = "templates/meldinn/images/help.png" border="0" alt="Info"></a>
<div id="container[[id]]" style="display:none">[[description]]<br></div>
{/html_table_adv}
I really appreciate any help here guys! Regards Oyvind
__________________
objelland V3.1.5b Developer |
|
|
|
|
|
#2 |
|
68 Classifieds Staff
Join Date: Mar 2006
Location: Belmont, NC
Posts: 5,118
Rep Power: 118 ![]() |
I think your html needs to look like this:
{html_table_adv loop=$cat_data cols=$cols table_attr='width="100%"'} <a id="moreLink" href="#" onClick="GetInfo('1');"> <img src = "templates/meldinn/images/help.png" border="0" alt="Info"></a> <div id="container1" style="display:none">[[description]]<br></div> {/html_table_adv}
__________________
Eric Barnes 68 Classifieds Developer Please do not send me a private message asking for support. Instead use these open forums or our ticket system. Customer Area | Issue Tracker | Documentation | 68C Mods | Submit a Ticket | 68 @ Twitter | My Modules |
|
|
|
|
|
#3 |
|
68 Evangelist & Developer
Join Date: Jan 2007
Location: Pennsylvania, USA
Posts: 1,624
Rep Power: 47 ![]() ![]() |
I don't really know javascript. I'm more of your copy and paste, but I use jquery and the jQpanels plugin to do that with.
jqpanels It's the accordion style. I've modified some of his code for my needs from time to time. Hope that helps, -Mike
__________________
Mike-N-Tosh IndianaPC.org - A community website (v3.1.10 Developer - heavily modified) Sandbox (v3.1.10, v4.0.9, 4.1.3) Visit My blog for tips, tricks, tutorials, reviews for 68 Classifieds as well as my store with Templates, Mods & Docs Web Hosting | Web Design & Development | 68 Classifieds Customizations I am not a 68C employee, just a user and try to help out |
|
|
|
|
|
#4 |
|
Member
Join Date: Dec 2006
Posts: 96
Rep Power: 12 ![]() |
Hi guys, thank you for you reply.
Eric: When I tested your code the text shows for like half a second and then I am directed to the home page. Strange!?! Take a look at http://www.landsnett.no/modules.php?mod=checkout and check it out. Any idea what might cause this? Oyvind
__________________
objelland V3.1.5b Developer |
|
|
|
|
|
#5 |
|
68 Classifieds Staff
Join Date: Mar 2006
Location: Belmont, NC
Posts: 5,118
Rep Power: 118 ![]() |
Try changing the link to this:
<a id="moreLink" href="javascript:void(0);" onClick="GetInfo('1');">
__________________
Eric Barnes 68 Classifieds Developer Please do not send me a private message asking for support. Instead use these open forums or our ticket system. Customer Area | Issue Tracker | Documentation | 68C Mods | Submit a Ticket | 68 @ Twitter | My Modules |
|
|
|
|
|
#6 |
|
68 Classifieds Staff
Join Date: Mar 2006
Location: Belmont, NC
Posts: 5,118
Rep Power: 118 ![]() |
On a side note you might want to check your email as we are getting returns from the one entered here on the forums.
__________________
Eric Barnes 68 Classifieds Developer Please do not send me a private message asking for support. Instead use these open forums or our ticket system. Customer Area | Issue Tracker | Documentation | 68C Mods | Submit a Ticket | 68 @ Twitter | My Modules |
|
|
|
|
|
#7 |
|
Member
Join Date: Dec 2006
Posts: 96
Rep Power: 12 ![]() |
Sorry for the e-mail thing, I have now updated it.
The script does not work. It shows the text, but the image dissapears and non of the other images (buttons) works after clicking on one of them. Hmmm.... I am not a javascript guru and I don't know what to look for at this stage. Oyvind
__________________
objelland V3.1.5b Developer |
|
|
|
|
|
#8 |
|
68 Classifieds Staff
Join Date: Mar 2006
Location: Belmont, NC
Posts: 5,118
Rep Power: 118 ![]() |
I just had a look and I think this is your issue:
Code:
<a id="moreLink" href="#" onClick="GetInfo('4702');">
<img src = "templates/meldinn/images/help.png" border="0" alt="Info"></a>
<div id="container1" style="display:none">
Code:
<a id="moreLink" href="javascript:void(0);" onClick="GetInfo('4702');">
<img src = "templates/meldinn/images/help.png" border="0" alt="Info"></a>
<div id="container4702" style="display:none">
__________________
Eric Barnes 68 Classifieds Developer Please do not send me a private message asking for support. Instead use these open forums or our ticket system. Customer Area | Issue Tracker | Documentation | 68C Mods | Submit a Ticket | 68 @ Twitter | My Modules |
|
|
|
|
|
#9 |
|
Member
Join Date: Dec 2006
Posts: 96
Rep Power: 12 ![]() |
hi
I have now tried all the possebilities suggested, but with no luck. The javascript:void(0) suggestion doesn't work either I am afraid. I am aware that this is not a javascript forum, but I would really appreciate if you have the time to take a closer look. Oyvind
__________________
objelland V3.1.5b Developer |
|
|
|
|
|
#10 |
|
68 Classifieds Staff
Join Date: Mar 2006
Location: Belmont, NC
Posts: 5,118
Rep Power: 118 ![]() |
Unfortunately I am not the best with javascript either. However if you look at the administration dashboard you will see how I set something similar up. It is the right side links.
__________________
Eric Barnes 68 Classifieds Developer Please do not send me a private message asking for support. Instead use these open forums or our ticket system. Customer Area | Issue Tracker | Documentation | 68C Mods | Submit a Ticket | 68 @ Twitter | My Modules |
|
|
|
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Javascript Problem | pschievink | v3.1 Questions & Support | 4 | 08-28-2007 07:14 AM |
| Javascript Question AJAX | Maffo | v3.1 Questions & Support | 5 | 05-24-2007 02:29 PM |
| How do I add something to the universal <head? (I want a new javascript declaration) | mike41 | v3.1 Questions & Support | 6 | 11-18-2006 09:26 AM |
| java and html | lbrown13 | HTML, CSS, and Design Help | 9 | 05-26-2006 12:54 PM |