/    Sign up×
Community /Pin to ProfileBookmark

Help with some code…

I’m having some diffculty in getting some code to work.

Basically, what I’ve attempted to do is to make a hyperlink appear, and when it’s clicked it should call a script that hides the label(of the link) and replaces it with the acutal URL. But the problem I keep having is the link label keeps trying to access a URL instead of the onclick event.

I’ll show the code, as maybe it will explain this a little better.

[Code]
function doEmailLink(suffix)
{
var rtn = true;
if(showObject(’emailVal’+suffix)) {
rtn = false;
hideObject(’emailLink’+suffix);
showObject(’emailLabel’+suffix);

}
return rtn;
}

function getObject(objID)
{
if (document.all)
{
var obj = document.all[objID];
}
else if (document.getElementById)
{
var obj = document.getElementById(objID);
}
return obj;
}

function hideObject(objID)
{
var obj = getObject(objID);
var rtn = false;
if (obj != null) {
obj.style.display = “none”;
rtn = true;
}
return rtn;
}

function showObject(objID)
{
var obj = getObject(objID);
var rtn = false;
if (obj != null) {
obj.style.display = “inline”;
obj.style.position = “static”;
obj.style.width = “auto”;
obj.style.height = “auto”;
obj.style.overflow = “visible”;
rtn = true;
}
return rtn;
}

<span class=”hidden” ID=”emailVal0″><br>Email: <a href=”mailto:[email protected]”>email</a></span>
<span ID=”emailLink0″><a title=”Show Email” onClick=”return doEmailLink(‘0’);” href=””>email</a></span>
<span style=”display: none;” ID=”emailLabel0″>email</span>

[/Code]

So those are the functions I’m using…basically, in this example of code I want it to just give me a hyperlink that says “Email” and when I click on it it replaces it with the actual URL, instead of it trying to open a new webpage. Can it be done this way? I’m a novice, but I really need to get this to work.

Thanks,
D

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@FangAug 31.2005 — Just use classes:function doEmailLink(suffix)
{
if(document.getElementById('emailVal'+suffix)) {
document.getElementById('emailLink'+suffix).className='hideIt';
document.getElementById('emailLabel'+suffix).className='showIt';
}
}
Copy linkTweet thisAlerts:
@dirt29authorAug 31.2005 — Thanks for the help...

That makes sense to use the classes to show/hide..

I just have a followup question. Your reply was pretty straight forward, even for a novice JS person such as myself. But, my real trouble is that all these email addresses are reading from a DB that uses VBScript in a loop until it gets to the EOF. Could you possibly help with the code needed to make that possible? I hate to be a pain, but I'd like to know how to make this work as I will need to incorporate other fields, as well as DBs with this method.

Thanks again,

D
×

Success!

Help @dirt29 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.20,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...