yumanbean
04-05-2007, 03:44 AM
I'm have a problem understanding how to pass the contents of variable thru a Show/hide function I use.
Here's the current function.
// functions to show/hide innerrightpages
function switchinnerrightid(innerrightid){
hideallinnerrightids();
showinnerrightdiv(innerrightid);
}
function hideallinnerrightids(){
//loop through the array and hide each element by id
for (var i=0;i<innerrightids.length;i++){
hideinnerrightdiv(innerrightids[i]);
}
}
function hideinnerrightdiv(innerrightid) {
//safe function to hide an element with a specified id
if (document.getElementById) {
document.getElementById(innerrightid).style.display = 'none';
}
else {
if (document.layers) {
document.innerrightid.display = 'none';
}
else {
document.all.innerrightid.style.display = 'none';
}
}
}
function showinnerrightdiv(innerrightid) {
//safe function to show an element with a specified id
if (document.getElementById) {
document.getElementById(innerrightid).style.display = 'block';
}
else {
if (document.layers) {
document.innerrightid.display = 'block';
}
else { // IE 4
document.all.innerrightid.style.display = 'block';
}
}
}
The function is called with switchinnerrightid(innerrightids) **var declaration below
VAR DECLARATION
var innerrightids;
innerrightids = new Array('dummyright','admart','rss','intro','comm2','contact2','myretrakker','featured','search','agen t');
OK this works fine. But what I need to do now is pass along a value when the div is shown. My thinking was to add it to the function such as:
function switchinnerrightid(innerrightid,getvar){
hideallinnerrightids();
showinnerrightdiv(innerrightid);
return getvar;
This where my meager javascript knowledge gets lost.
Note: this variable is a DB id that I need to populate the div when it shows. Here's how I actually call the function in the code:
echo "<div dojoType='FisheyeListItem' id='" . $agentUsrID . "' javascript:var gGetVar='" . $agentUsrID . "'; onclick=\"javascript:switchid('homecont');switchinnerleftid('map');switchinnerrightid('dummyright');switchinne rrightid('agent','" . $agentUsrID . "');\" caption='" . $agentfname . "'iconsrc='images/agents/" . $row['HiddenUsrID'] . ".jpg'>";
Declaring the variable has got me stumped. When the div is switched the var getvar is undefined.
Any help on this issue would be greatly appreciated.
Here's the current function.
// functions to show/hide innerrightpages
function switchinnerrightid(innerrightid){
hideallinnerrightids();
showinnerrightdiv(innerrightid);
}
function hideallinnerrightids(){
//loop through the array and hide each element by id
for (var i=0;i<innerrightids.length;i++){
hideinnerrightdiv(innerrightids[i]);
}
}
function hideinnerrightdiv(innerrightid) {
//safe function to hide an element with a specified id
if (document.getElementById) {
document.getElementById(innerrightid).style.display = 'none';
}
else {
if (document.layers) {
document.innerrightid.display = 'none';
}
else {
document.all.innerrightid.style.display = 'none';
}
}
}
function showinnerrightdiv(innerrightid) {
//safe function to show an element with a specified id
if (document.getElementById) {
document.getElementById(innerrightid).style.display = 'block';
}
else {
if (document.layers) {
document.innerrightid.display = 'block';
}
else { // IE 4
document.all.innerrightid.style.display = 'block';
}
}
}
The function is called with switchinnerrightid(innerrightids) **var declaration below
VAR DECLARATION
var innerrightids;
innerrightids = new Array('dummyright','admart','rss','intro','comm2','contact2','myretrakker','featured','search','agen t');
OK this works fine. But what I need to do now is pass along a value when the div is shown. My thinking was to add it to the function such as:
function switchinnerrightid(innerrightid,getvar){
hideallinnerrightids();
showinnerrightdiv(innerrightid);
return getvar;
This where my meager javascript knowledge gets lost.
Note: this variable is a DB id that I need to populate the div when it shows. Here's how I actually call the function in the code:
echo "<div dojoType='FisheyeListItem' id='" . $agentUsrID . "' javascript:var gGetVar='" . $agentUsrID . "'; onclick=\"javascript:switchid('homecont');switchinnerleftid('map');switchinnerrightid('dummyright');switchinne rrightid('agent','" . $agentUsrID . "');\" caption='" . $agentfname . "'iconsrc='images/agents/" . $row['HiddenUsrID'] . ".jpg'>";
Declaring the variable has got me stumped. When the div is switched the var getvar is undefined.
Any help on this issue would be greatly appreciated.