/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] Can you see the error of my ways?

I’m not getting any errors in the following script, but I’m not seeing any change either. 😮
Anyone see my error? ?
My eyes must be going bad. 😮

[code=php]
<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01//EN” “http://www.w3.org/TR/html4/strict.dtd”>
<html lang=”en”>
<head>
<title>Basic TAB display</title>
<meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″>

<script type=”text/javascript”>
var Info = new Array();
var str = ”;
str = “<h1>Tab Info #1</h1>”; Info[0] = str;
str = “<h2>Tab Info #2</h2>”; Info[1] = str;
str = “<h3>Tab Info #3</h3>”; Info[2] = str;
str = “Tab Info #4”; Info[3] = str;
str = “Tab Info #5”; Info[4] = str;

function Show(IDS) {
var ids; // alert(‘IDS: ‘+IDS);
for (i=0; i<Info.length; i++) {
ids = ‘btnTab’+i;
document.getElementById(ids).style.backgroundColor = “#FFFFFF”;
}
var N = IDS.charAt(-1); // alert(‘N: ‘+N);
document.getElementById(IDS).style.backgroundColor = “#FFFF00″;
document.getElementById(‘TabInfo’).innerHTML = Info[N];
}
</script>

<style type=”text/css”>
#TabInfo {
border: 1px solid blue;
height:200px;
width:300px;
}
</style>

</head>
<body>
<div>
<button id=”btnTab0′ onclick=”Show(this.id)”>Tab 1</button>
<button id=”btnTab1′ onclick=”Show(this.id)”>Tab 2</button>
<button id=”btnTab2′ onclick=”Show(this.id)”>Tab 3</button>
<button id=”btnTab3′ onclick=”Show(this.id)”>Tab 4</button>
<button id=”btnTab4′ onclick=”Show(this.id)”>Tab 5</button>
</div>
<div id=”TabInfo”></div>
</body>
</html>
[/code]

Thanks for looking.

to post a comment
JavaScript

5 Comments(s)

Copy linkTweet thisAlerts:
@mrhooMay 31.2008 — var N = IDS.charAt(-1) should maybe be N= Number(IDS.charAt(IDS.length-1))
Copy linkTweet thisAlerts:
@FangMay 31.2008 — var N = IDS.charAt(IDS.length-1);
and typos:&lt;div&gt;
&lt;button id="btnTab0[B][COLOR="Red"]'[/COLOR][/B] onclick="Show(this.id)"&gt;Tab 1&lt;/button&gt;
&lt;button id="btnTab1[B][COLOR="Red"]'[/COLOR][/B] onclick="Show(this.id)"&gt;Tab 2&lt;/button&gt;
&lt;button id="btnTab2[B][COLOR="Red"]'[/COLOR][/B] onclick="Show(this.id)"&gt;Tab 3&lt;/button&gt;
&lt;button id="btnTab3[B][COLOR="Red"]'[/COLOR][/B] onclick="Show(this.id)"&gt;Tab 4&lt;/button&gt;
&lt;button id="btnTab4[B][COLOR="Red"]'[/COLOR][/B] onclick="Show(this.id)"&gt;Tab 5&lt;/button&gt;
&lt;/div&gt;
Copy linkTweet thisAlerts:
@NedalsMay 31.2008 — A little simpler, me thinks. ?
<i>
</i>&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"&gt;
&lt;html lang="en"&gt;
&lt;head&gt;
&lt;title&gt;Basic TAB display&lt;/title&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8"&gt;

&lt;script type="text/javascript"&gt;
var Info = new Array(
"&lt;h1&gt;Tab Info #1&lt;/h1&gt;",
"&lt;h2&gt;Tab Info #2&lt;/h2&gt;",
"&lt;h3&gt;Tab Info #3&lt;/h3&gt;",
"Tab Info #4",
"Tab Info #5"
);

function Show(n) {
for (i=0; i&lt;Info.length; i++) {
document.getElementById('btnTab'+i).style.background = "#FFFFFF";
}
document.getElementById('btnTab'+n).style.background = "#FFFF00";
document.getElementById('TabInfo').innerHTML = Info[n]; <br/>
}
&lt;/script&gt;

&lt;style type="text/css"&gt;
#TabInfo {
border: 1px solid blue;
height:200px;
width:300px;
}
&lt;/style&gt;

&lt;/head&gt;
&lt;body&gt;
&lt;div&gt;
&lt;button id="btnTab0" onclick="Show(0)"&gt;Tab 1&lt;/button&gt;
&lt;button id="btnTab1" onclick="Show(1)"&gt;Tab 2&lt;/button&gt;
&lt;button id="btnTab2" onclick="Show(2)"&gt;Tab 3&lt;/button&gt;
&lt;button id="btnTab3" onclick="Show(3)"&gt;Tab 4&lt;/button&gt;
&lt;button id="btnTab4" onclick="Show(4)"&gt;Tab 5&lt;/button&gt;
&lt;/div&gt;
&lt;div id="TabInfo"&gt;&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
Copy linkTweet thisAlerts:
@FangMay 31.2008 — var Info = [
"&lt;h1&gt;Tab Info #1&lt;/h1&gt;",
"&lt;h2&gt;Tab Info #2&lt;/h2&gt;",
"&lt;h3&gt;Tab Info #3&lt;/h3&gt;",
"Tab Info #4",
"Tab Info #5"
];

Always room for improvement ?

http://www.w3.org/TR/html401/interact/scripts.html#h-18.2.4
Copy linkTweet thisAlerts:
@JMRKERauthorMay 31.2008 — Thank you all.

All of you have good eyes and good suggestions.

Appreciate it very much.
×

Success!

Help @JMRKER 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 4.29,
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: @Yussuf4331,
tipped: article
amount: 1000 SATS,

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

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...