/    Sign up×
Community /Pin to ProfileBookmark

Request for help on the code

Hi,

I have a code which is not working in webpage. It works when I save the code as a html file and open in browser but when I put the code to a webpage, it does not work correctly. See below how it shows in webpage:
[ATTACH]16307[/ATTACH]

I want it to be displayed as below:
[ATTACH]16309[/ATTACH]

Below is the clde I have used. Can anyone please help in fixing it. I don’t know why it is not showing correctly in webpage.

[code=html]
<meta content=”en-us” http-equiv=”Content-Language”>
<title></title>
<script>
var toggledDisplay = new Object();
toggledDisplay[‘sub1’] = true;
toggledDisplay[‘sub2’] = true;
toggledDisplay[‘sub3’] = true;

function toggleDisplay(bDisplayed) {
if (!document.getElementById || toggleDisplay.arguments.length < 2) return;
var displayed = new Object();
displayed[‘true’] = ‘block’;
displayed[‘false’] = ‘none’;
for (var i = 1; i < toggleDisplay.arguments.length; i++) {
oDisplay = document.getElementById(toggleDisplay.arguments[i]);
if (oDisplay) {
oDisplay.style.display = displayed[bDisplayed];
if (bDisplayed) {
oImages = oDisplay.getElementsByTagName(‘IMG’);
for (var j = 0; j < oImages.length; j++)
oImages[j].src = oImages[j].src;
}
if (typeof toggledDisplay[toggleDisplay.arguments[i]] != ‘undefined’)
toggledDisplay[toggleDisplay.arguments[i]] = !bDisplayed;
}
}
}
</script>
<!–mstheme–>
<link href=”../../_themes/Lacquer/Lacq1011.css” id=”onetidThemeCSS” rel=”stylesheet” type=”text/css”>
<meta content=”Lacquer 1011, default” name=”Microsoft Theme”>
<div><a href=”JavaScript://” onclick=”toggleDisplay(true, ‘sub1’, ‘sub2’, ‘sub3’ , ‘sub4’, ‘sub5’, ‘sub6’, ‘sub7’);”>Expand All</a> | <a href=”JavaScript://” onclick=”toggleDisplay(false, ‘sub1’, ‘sub2’, ‘sub3’ , ‘sub4’, ‘sub5’, ‘sub6’, ‘sub7’);”>Collapse All</a> <font color=”#000000″> </font>
<table border=”1″ style=”width: 100%;”>
<tbody>
<tr>
<td colspan=”2″>Page Title</font>
</td>
</tr>
<tr>
<td class=”rtecenter” style=”width: 50%; background-color: rgb(255, 102, 0);”><span style=”color:#000000;”><strong>AAA</strong></span>
</td>
<td class=”rtecenter” style=”width: 50%; background-color: rgb(255, 102, 0);”><span style=”color:#000000;”><strong>BBB</strong></span>
</td>
</tr>
<tr>
<td colspan=”2″ style=”background-color: rgb(0, 102, 204);”><a href=”JavaScript://” onclick=”toggleDisplay(toggledDisplay[‘sub1’], ‘sub1’)”><span style=”color:#FFFFFF;”><strong>Section 1 – Click to Expand / Collapse</strong></span></a>
</td>
</tr>
<tr id=”sub1″>
<td colspan=”2″>
<table border=”1″ style=”width: 100%;”>
<tbody>
<tr>
<td style=”width: 50%;”><font color=”#000000″>AA</font>
</td>
<td style=”width: 50%;”><font color=”#000000″>11</font>
</td>
</tr>
<tr>
<td><font color=”#000000″>BB</font>
</td>
<td><font color=”#000000″>22</font>
</td>
</tr>
<tr>
<td><font color=”#000000″>CC</font>
</td>
<td><font color=”#000000″>ABCDEFGHIJKLMN & OPQRSTUVWXYZ</font>
</td>
</tr>
</td>
</table>
</tr>

<tr>
<td colspan=”2″ style=”background-color: rgb(0, 102, 204);”><a href=”JavaScript://” onclick=”toggleDisplay(toggledDisplay[‘sub2’], ‘sub2’)”><span style=”color:#FFFFFF;”><strong>Section 2 – Click to Expand / Collapse</strong></span></a>
</td>
</tr>
<tr id=”sub2″>
<td colspan=”2″>
<table border=”1″ style=”width: 100%;”>
<tbody>
<tr>
<td style=”width: 50%;”><font color=”#000000″>AA</font>
</td>
<td style=”width: 50%;”><font color=”#000000″>11</font>
</td>
</tr>
<tr>
<td><font color=”#000000″>BB</font>
</td>
<td><font color=”#000000″>22</font>
</td>
</tr>
<tr>
<td><font color=”#000000″>CC</font>
</td>
<td><font color=”#000000″>ABCDEFGHIJKLMN & OPQRSTUVWXYZ</font>
</td>
</tr>
</td>
</table>
</tr>

</tbody>
</table>
</td>
</tr>
</tbody>
</table>
<font color=”#000000″> </font>
<script language=”JavaScript” type=”text/javascript”>
<!–
toggleDisplay(false, ‘sub1’, ‘sub2’, ‘sub3’, ‘sub4’, ‘sub5’, ‘sub6’, ‘sub7’);
toggleDisplay(true, ‘toggleAll’);
//–>
</script>
</div>
[/code]

[canned-message]attachments-removed-during-migration[/canned-message]

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@rootAug 16.2014 — What makes you think that what you have posted is JQuery?

Skimming it it looks all JavaScript to me...

When posting, it is helpful to wrap any code segments in the appropriate tags which are CODE, PHP or HTML

eg.

[B][[/B][B]CODE][/B] // your code in here [B][/[/B][B]CODE][/B]

then outputs
[CODE] // your code in here [/CODE]

I have tried your code and it as far as I can see works fine when a few minor changes are made to the HTML like adding a <body> tag, enclosing the JavaScript and title and meta tad within the <head>...</head> of the document.

What I think is the problem is a CSS layout issue and something that you might want to ask for help in the CSS forums.
Copy linkTweet thisAlerts:
@phani_patilauthorAug 18.2014 — Hi,

Thank you for your response. I will keep your suggestions in mind when posting again. Thank you!

My issue got resolved. There was some error in the code and it got fixed. Thanks for trying to help me o the issue!
×

Success!

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