473,386 Members | 1,752 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

using javascript with the DOM

hello, i have a question on using javascript with the DOM
can anyone help me out
i have a function that has a number passed to it
the variable is called "bioId"

function visible(bioId);

this number ranges between 1 and 6
there is a statement in the function

document.bio.display = 'none';

i want the statement to change depending on what number i pass to the
function
so lets say I pass a 3
i want that statement to say

document.bio3.display = 'none';

is there a way to do this?
something like
document.bio{bioId}.display = 'none';
Jul 23 '05 #1
2 1006
test <te**@test.com> writes:
i have a function that has a number passed to it
the variable is called "bioId" .... so lets say I pass a 3
i want that statement to say

document.bio3.display = 'none';
First of all, you should not write
document.bio3
to refer to an element with name "bio3". The proper way would
be
document.getElementById("bio3")
possibly with fallbacks for old browsers.
<URL:http://jibbering.com/faq/#FAQ4_41>

If the element is a form or image, you can use the collections
instead:
document.forms['bio3']
or
document.images['bio3']

Second, elements don't usually have a display property. It seems your
code was written for Netscape 4, and it probably won't work very well
anywhere else. The correct display property is in the style object.

That answers the question:
document.getElementById("bio"+bioId).style.display ="none";
(or
document.images["bio"+bioId].style.display = "none";
is there a way to do this?
something like
document.bio{bioId}.display = 'none';


This FAQ entry is close:
<URL:http://jibbering.com/faq/#FAQ4_39>

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 23 '05 #2
"test" <te**@test.com> wrote in message
news:040420040001511853%te**@test.com...
hello, i have a question on using javascript with the DOM
can anyone help me out
i have a function that has a number passed to it
the variable is called "bioId"

function visible(bioId);

this number ranges between 1 and 6
there is a statement in the function

document.bio.display = 'none';

i want the statement to change depending on what number i pass to the
function
so lets say I pass a 3
i want that statement to say

document.bio3.display = 'none';

is there a way to do this?
something like
document.bio{bioId}.display = 'none';


document.getElementById("bio" + bioId).display = 'none';

--
Dag.
Jul 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
by: Mel | last post by:
if you know of dynamic expandable folder using CSS and display function, please drop me a note Yours, Mel
13
by: Stumped and Confused | last post by:
Hello, I really, really, need some help here - I've spent hours trying to find a solution. In a nutshell, I'm trying to have a user input a value in form's textfield. The value should then be...
7
by: Privacy Advocate | last post by:
//crossposted to: comp.lang.javascript, alt.comp.lang.javascript in an effort to get factual answers from JavaScript experts// Simply put; Is it possible to obtain the real (actual) IP address of...
0
by: Michelle Keys | last post by:
I am trying to call a print function to print a string from a database using javascript. Which is RC_DATA of Varchar2(2500). This is a javascript is not being used. I have a thing that needs to...
2
by: Jeronimo Bertran | last post by:
A couple of questions I am having problems with converting my JavaScript to C#. I have the following code using JavaScript for the mouseover handler that works fine: <SCRIPT...
2
by: Jake Barnes | last post by:
Using javascript closures to create singletons to ensure the survival of a reference to an HTML block when removeChild() may remove the last reference to the block and thus destory the block is...
8
by: Nathan Sokalski | last post by:
I add a JavaScript event handler to some of my Webcontrols using the Attributes.Add() method as follows: Dim jscode as String = "return (event.keyCode>=65&&event.keyCode<=90);"...
0
AnuSumesh
by: AnuSumesh | last post by:
Hi All, I want to call RDP on Page load and it is working fine.My code is in C#. But I am unable to perform following functions 1. when i disconnected from RDP, i want to go back to...
7
by: JDOMPer | last post by:
Don’t misunderstand me – I use AJAX, but I think there is a far simpler, elegant alternative that just uses Javascript, the DOM and Php ( hence - JDOMP) for data transfers, and is cross-browser...
6
Frinavale
by: Frinavale | last post by:
Apparently I have a lot of questions today regarding JavaScript security. I've implemented a JavaScript Object that intercepts page submits (postbacks) and then displays a UI prompting the user...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.