/    Sign up×
Community /Pin to ProfileBookmark

Trouble outputting a JavaScript Function within an html jump menu

Here is a tough one, or at lease for me it is…

I am new to JavaScript, so please go light on me if I get the termonolgy incorrect. Here is what I am trying to do…

In the following line of code I would like to make the template ID dynamic so that I can access the “computers” group from any tmeplate on my site.:

<option class=”link” value=”http://myDevSite/scripts/ecatalogisapi.dll/Group?Group=21&Template=9990000105000999“> » Computers</option>

I have already written JavaScript to pull the template number from the URL string and it works just fine when used as follows:

<script>document.write(“<a href=’http://myDevSite/scripts/ecatalogisapi.dll/Group?Group=21&Template=” + GetTemplateId() + “‘ class=newsidebar>Computers</a>”);</script>

When I use teh above code on a template the GetTemplateId is nicely replaced with whatever template number is being displayed in the pages URL.

I need to be able to use GetTemplateId() in place of the static number in the html jump menu’s code I have shown above – I cannot get it to work.

Any help would be greatly appreciated…I am loosing my hair fast enough naturally…I can’t afford to continue pulling more of it out!

Regards,
photopro23

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@Mr_JFeb 23.2007 — See if this example is what your after

[code=php]<script>

function GetTemplateId(){

value="12345"

return value


}

</script>

<script>
document.write("<a href='http://myDevSite/scripts/ecatalogisapi.dll/Group?Group=21&Template=" + GetTemplateId() + "' class=newsidebar>Computers</a>");
</script>[/code]


Although reading through your post again I may have misunderstood, is it in the option you want to use GetTemplateID()
Copy linkTweet thisAlerts:
@photopro23authorFeb 23.2007 — Hi Mr J...yes you are correct that it IS in the "option" I want to see GetTemplateId()

Thanks!
×

Success!

Help @photopro23 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.18,
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,
)...