/    Sign up×
Community /Pin to ProfileBookmark

Javascript code to "repeat" button menu

Hi Folks,

I have a tiny set of two buttons that I display inside a table, sorta like this:
[COLOR=Red]<TABLE>
<TR>
<TD>
Roll-Over button #1, and link starement
</TD>
<TD>
Roll-Over button #2, and link starement
</TD>
</TR>
</TABLE>
[/COLOR]

My issue is that this same code is sprinkled all over my various web pages, perhaps 15 times so far and growing.

I would like to contain that Table-Code in one place and then refer to it from all of the pages it now appears.
I tried containing the code in a function statement placed in a JS file,
[COLOR=Red]function showButtons()
{
Copied the table code
}
[/COLOR]

Then, in place of ALL the Table-Code on the pages just entered:
[COLOR=Red]showButtons()[/COLOR]

Naturally, it didn’t work.

Can someone show me how to “repeat” duplicate Table-Code properly?

Many thanks
-Paul-

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@nzakasAug 18.2005 — It's not clear from your description, but you probably want something like this:

<i>
</i>function showButtons(){
document.write("&lt;table&gt;&lt;tr&gt;&lt;td&gt;" + link_stuff + "&lt;/td&gt;&lt;td&gt;" + link_stuff2 + "&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;");
}


Then call it in your page like this:

[code=html]
<script>
showButtons();
</script>
[/code]
×

Success!

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