I hope someone can help me here. I’m a PHP type of guy rather than javascript but I found some nice JS that I want to use on my page together with some php coding.
The problem seems to be that the JS code won’t pass some of my php code to the server properly and I don’t know how I can get around it.
Heres the script in the header:
[code]
<script type=”text/javascript”>
// <![CDATA[
// Tab menu functions by Jack Letourneau, February 2002
// [url]http://eigengrau.com/[/url]
function switchOn(tab,contents) {
// Pass it a tab ID and a contents ID, single-quoted:
// switchOn(‘tab1′,’contents1’)
// Sets all tabs and contents to inactive state, then
// activates the tab/contents passed as parameters
switchAllOff();
document.getElementById(tab).className = ‘selectedtab’;
document.getElementById(contents).className = ‘selectedcontents’;
}
function clearTop() {
// Sets all tabs to inactive state. Depends on the TR
// enclosing the tabs having ID “toprow”
topRow = document.getElementById(‘toprow’);
tabArray = topRow.childNodes;
for (var i=0; i<tabArray.length; i++) {
if (tabArray[i].className != ‘tabspacer’) {
tabArray[i].className = ‘tab’;
}
}
}
function clearContents() {
// Hides all DIVs in TD ID=”contentscell”
contentsCell = document.getElementById(‘contentscell’);
contentsArray = contentsCell.childNodes;
for (var j=0; j<contentsArray.length; j++) {
contentsArray[j].className = ‘contents’;
}
}
function switchAllOff() {
// Trivial little wrapper function; sets all tabs and
// contents to inactive/invisible state
clearTop();
clearContents();
}
// ]]>
</script>
And what I’m trying to do:
[code]
<table id=”tabmenu” border=”0″ cellpadding=”0″ cellspacing=”0″ width=”800″>
<thead>
<tr id=”toprow”>
<td class=”tab” id=”tab1″><div onclick=”switchOn(‘tab1′,’contents1’);”>What’s New</div></td>
<td class=”tabspacer”> </td>
<td class=”tab” id=”tab2″><div onclick=”switchOn(‘tab2′,’contents2’);”>Bulletin Board</div></td>
<td class=”tabspacer”> </td>
<td class=”tab” id=”tab3″><div onclick=”switchOn(‘tab3′,’contents3’);”>Technical Update</div></td>
<td class=”tabspacer”> </td>
<td class=”tab” id=”tab4″><div onclick=”switchOn(‘tab4′,’contents4’);”>Knowledge Base</div></td>
<td class=”tabspacer”> </td>
<td class=”tab” id=”tab5″><div onclick=”switchOn(‘tab5′,’contents5’);”>Useful Info</div></td>
</tr>
</thead>
<tbody>
<tr>
<td id=”contentscell” colspan=”9″>
<div class=”contents” id=”contents1″><?php include “update/view.php?category=training&playout=1″ ; ?></div>
<div class=”contents” id=”contents2″><?php include “forum/forumlist.php” ; ?></div>
<div class=”contents” id=”contents3″><?php include “test.php” ; ?></div>
<div class=”contents” id=”contents4″>Nihilne te nocturnum praesidium Palati, nihil urbis vigiliae…</div>
<div class=”contents” id=”contents5″>Nihil timor populi, nihil concursus bonorum omnium, etc.</div>
</td>
</tr>
</tbody>
</table>
The problem is where I am trying to make the content of ‘contents2’ to be a php include. I want to call a php script and send some variables to it like ‘category=training&playout=1’ but although I can call the script okay as content – trying to add the extra variables to the string stops the javascript from working.
My question is how can I pass those variables through the javascript to the php page?
Hope I’ve explained that okay.