Register and join over 40,000 other developers!
Recent Topics
-
Print specific values from dictionary with a specific key name
Siten0308 - Jun 20 2019 01:43 PM
-
Learn algorithms and programming concepts
johnnylo - Apr 23 2019 07:49 AM
-
Job Gig PHP Form Needed
PJohnson - Apr 18 2019 03:55 AM
-
How to make code run differently depending on the platform it is running on?
xarzu - Apr 05 2019 09:17 AM
-
How do I set a breakpoint in an attached process in visual studio
xarzu - Apr 04 2019 11:47 AM
Recent Blog Entries
Recent Status Updates
Popular Tags
- networking
- Managed C++
- stream
- console
- database
- authentication
- Visual Basic 4 / 5 / 6
- session
- Connection
- asp.net
- import
- syntax
- hardware
- html5
- array
- mysql
- java
- php
- c++
- string
- C#
- html
- loop
- timer
- jquery
- ajax
- javascript
- programming
- android
- css
- assembly
- c
- form
- vb.net
- xml
- linked list
- login
- encryption
- pseudocode
- calculator
- sql
- python
- setup
- help
- game
- combobox
- binary
- hello world
- grid
- innerHTML

A simple program
Started by bluefenix, Sep 17 2012 03:59 PM
calling variables function onload onload function easy
1 reply to this topic
#1
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";
}
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";
}
#2
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
you can make hidden the default style, i guess your program will work the same since i think you activate them later
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

you can make hidden the default style, i guess your program will work the same since i think you activate them later
Also tagged with one or more of these keywords: calling variables function, onload, onload function, easy
Language Forums →
HTML, CSS and Javascript →
Can not get value from onload properties of FileReaderStarted by Ehsan0101, 12 Aug 2014 ![]() |
|
![]() |
||
Language Forums →
Java →
Trouble with Transposing a 2D ArrayStarted by Andex, 16 Feb 2014 ![]() |
|
![]() |
||
General Forums →
General Programming →
Cd unit open and close programStarted by brainiac080195, 17 Apr 2013 ![]() |
|
![]() |
||
Language Forums →
HTML, CSS and Javascript →
A simple program [alert("Something") && checkbox.checked]Started by bluefenix, 13 Aug 2012 ![]() |
|
![]() |
||
Tutorial Forums →
Other Programming Tutorials →
Video Tutorials →
How To Use A ConstructorStarted by compscistudio, 22 Apr 2012 ![]() |
|
![]() |
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download