Support Forums

Old 03-27-2008, 03:32 PM   #1
Member
 
Join Date: Dec 2006
Posts: 96
Rep Power: 12
objelland is on a distinguished road
Exclamation Javascript - HELP!!

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}
The HTML looks as follows:

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}
Can anyone see what's wrong? What happens is that when a quesionmark "button" is clicked on, the link is directing to the home page of my site.

I really appreciate any help here guys!

Regards
Oyvind
__________________
objelland
V3.1.5b Developer
objelland is offline   Reply With Quote
Old 03-27-2008, 03:38 PM   #2
68 Classifieds Staff
 
 
Join Date: Mar 2006
Location: Belmont, NC
Posts: 5,118
Rep Power: 118
Eric Barnes is a jewel in the rough
Default

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
Eric Barnes is offline   Reply With Quote
Old 03-27-2008, 03:40 PM   #3
68 Evangelist & Developer
 
 
Join Date: Jan 2007
Location: Pennsylvania, USA
Posts: 1,624
Rep Power: 47
Mike-N-Tosh is just really niceMike-N-Tosh is just really nice
Default

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
Mike-N-Tosh is offline   Reply With Quote
Old 03-27-2008, 03:47 PM   #4
Member
 
Join Date: Dec 2006
Posts: 96
Rep Power: 12
objelland is on a distinguished road
Default

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
objelland is offline   Reply With Quote
Old 03-27-2008, 03:54 PM   #5
68 Classifieds Staff
 
 
Join Date: Mar 2006
Location: Belmont, NC
Posts: 5,118
Rep Power: 118
Eric Barnes is a jewel in the rough
Default

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
Eric Barnes is offline   Reply With Quote
Old 03-27-2008, 03:58 PM   #6
68 Classifieds Staff
 
 
Join Date: Mar 2006
Location: Belmont, NC
Posts: 5,118
Rep Power: 118
Eric Barnes is a jewel in the rough
Default

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
Eric Barnes is offline   Reply With Quote
Old 03-27-2008, 04:09 PM   #7
Member
 
Join Date: Dec 2006
Posts: 96
Rep Power: 12
objelland is on a distinguished road
Default

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
objelland is offline   Reply With Quote
Old 03-27-2008, 04:14 PM   #8
68 Classifieds Staff
 
 
Join Date: Mar 2006
Location: Belmont, NC
Posts: 5,118
Rep Power: 118
Eric Barnes is a jewel in the rough
Default

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">
It should be:
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
Eric Barnes is offline   Reply With Quote
Old 03-27-2008, 04:30 PM   #9
Member
 
Join Date: Dec 2006
Posts: 96
Rep Power: 12
objelland is on a distinguished road
Default

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
objelland is offline   Reply With Quote
Old 03-27-2008, 04:57 PM   #10
68 Classifieds Staff
 
 
Join Date: Mar 2006
Location: Belmont, NC
Posts: 5,118
Rep Power: 118
Eric Barnes is a jewel in the rough
Default

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
Eric Barnes is offline   Reply With Quote

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


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


All times are GMT -4. The time now is 06:59 PM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0