Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

A simple program

calling variables function onload onload function easy

  • Please log in to reply
1 reply to this topic

#1 bluefenix

bluefenix

    CC Newcomer

  • Member
  • PipPip
  • 11 posts
  • Programming Language:Java, PHP, PL/SQL
  • Learning:C#, JavaScript, Visual Basic .NET

Posted 17 September 2012 - 03:59 PM

Im having troubble with this program, I need two functions the window.onload one will hide all the divs when the page loads. The variables declarations are fine, since I tested in the original one to hide some divs and show other when select box selected. For example when selected men(option) will show "Divs Men" and when women(option) is selected it will show "Divs Women". It works fine, Im just having troubble when I add the onloadFunction, I think maybe Im mistaking in calling the variables of function shoesOne to function default(the onload one). Or maybe Im declaring wrongly the onload function Any help is appreciated.

function shoesOne()
{

//**

//Divs Men
var colorWD= document.getElementById("selectDiv1");
var paraWD= document.getElementById("selectDiv2");

//Divs Women
var marcaMD= document.getElementById("selectDiv02");
var puntaD= document.getElementById("selectDiv03");
var cierreD= document.getElementById("selectDiv04");
var suelasD= document.getElementById("selectDiv05");
}


window.onload= function default()
{ //Men
colorWD.style.display= "none";
paraWD.style.display= "none";

//Women
marcaMD.style.display= "none";
puntaD.style.display= "none";
cierreD.style.display= "none";
suelasD.style.display= "none";
}
  • 0

#2 BlackRabbit

BlackRabbit

    CodeCall Legend

  • Expert Member
  • PipPipPipPipPipPipPipPip
  • 3871 posts
  • Location:Argentina
  • Programming Language:C, C++, C#, PHP, JavaScript, Transact-SQL, Bash, Others
  • Learning:Java, Others

Posted 17 September 2012 - 04:04 PM

I can tell you a couple of thing about this my Spanish talking friend, which i guess from the variable names.

You are correct about being a problem calling the variables, which could be solved if you declare those vars as global (at the start of script, outside any function )

i can't help to ask, why don't you create them hidden ? so you don't need to hide them in the onload :D
you can make hidden the default style, i guess your program will work the same since i think you activate them later
  • 1





Also tagged with one or more of these keywords: calling variables function, onload, onload function, easy

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download