Please login or register. Welcome to the Studio, guest!


Quick Links:


newBookmarkLockedFalling

Andrew McGivery

Andrew McGivery Avatar
Formerly Fredy

******
Legendary Studio Member

Male
5,742


September 2005
ok.. so i have these functions which are all simular...


function switch1(){
var content = document.getElementById("info")
var content2 = document.getElementById("foruminfo").innerHTML;
content.innerHTML = content2
}
function switch2(){
var content = document.getElementById("info")
var content2 = document.getElementById("memberinfo").innerHTML;
content.innerHTML = content2
}
function switch3(){
var content = document.getElementById("info")
var content2 = document.getElementById("currentinfo").innerHTML;
content.innerHTML = content2
}
function switch4(){
var content = document.getElementById("info")
var content2 = document.getElementById("pminfo").innerHTML;
content.innerHTML = content2
}
function switch5(){
var content = document.getElementById("info")
var content2 = document.getElementById("eventinfo").innerHTML;
content.innerHTML = content2
}


I'd like to simplify it to just one function where i can use switch(id); where i want to use it. Help. :P

k

(¯`•DregondRahl•._)

(¯`•DregondRahl•._) Avatar
Remanifesting-Eternal

***
Dedicated Member

239


September 2006
tried this?

function switch1(id){
        var content = document.getElementById("info")
        var content2 = document.getElementById(id).innerHTML;
                content.innerHTML += content2
}





Mithras

Mithras Avatar

****
Studio Member

600


July 2006
dregondrahl said:
tried this?

function switch1(id){
var content = document.getElementById("info")
var content2 = document.getElementById(id).innerHTML;
content.innerHTML += content2
}



function switch1(id){
var content = document.getElementById("info")
var content2 = document.getElementById(id).innerHTML;
content.innerHTML = content2
}


One little mistake. He wanted content.innerHTML = content2 ;)


Support Rob Scuderi, the #1 Penguins Defender!

lucifer said:
"Behold: me! I have authority in this building."

Andrew McGivery

Andrew McGivery Avatar
Formerly Fredy

******
Legendary Studio Member

Male
5,742


September 2005
Works like a charm. Thanks guys ^_^
k

(¯`•DregondRahl•._)

(¯`•DregondRahl•._) Avatar
Remanifesting-Eternal

***
Dedicated Member

239


September 2006
no prob, oh and i added the "+=" so if you wanted to add two two different node's innerHTML to the same "info" node, it would work without replace it.




Andrew McGivery

Andrew McGivery Avatar
Formerly Fredy

******
Legendary Studio Member

Male
5,742


September 2005
yes i know that much... i just couldn't figure out the id part... lol
k

newBookmarkLockedFalling