JavaScript Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsWeb DesignJavaScript Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old April 29th, 2002, 05:11 AM
AnthemisCretica AnthemisCretica is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2002
Posts: 8 AnthemisCretica User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question DHTML, visibility, etc

hi,
i cant make the following basic DHTML work. Porpuse is, when mouse is clicked, make some part of page visible. but nothing hapenned ! except an instant note on status bar: error on page :)

where is the error ?
thanks for coming helps...

ps1: both 'this.name' property and id name function calling didnt work
ps2: i use IE 5.0 how can i see javascript errors at IE ? as in NN6.0 when "javascript: " is written in address bar

--- HTML CODE :
<script type="text/javascript">
function makevisible (spanname) {
spanname.style.visibility="visible"
}
</script>
<body>
<ul>
<li> <a href="javascript:makevisible(this.name)" name="span_one"> html </a>
<li> <a href="javascript:makevisible(span_two)" name="span_two"> jscript </a>
</ul>

<span id="span_one" style="visibility:hidden" >
bla bla bla of html
</span>
<p>
<span id="span_two" style="visibility:hidden" >
bla bla bla of javascript
</span>
-----------------------------

thnx.

Reply With Quote
  #2  
Old April 29th, 2002, 05:28 AM
binky's Avatar
binky binky is offline
Gerbil
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Oct 2001
Location: In a Rotastak
Posts: 1,763 binky User rank is Sergeant (500 - 2000 Reputation Level)binky User rank is Sergeant (500 - 2000 Reputation Level)binky User rank is Sergeant (500 - 2000 Reputation Level)binky User rank is Sergeant (500 - 2000 Reputation Level)binky User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 22 h 12 m 52 sec
Reputation Power: 19
document.getElementById(spanname).style.visiblity = "visible"

??
__________________
- Sorted!

www.ppfuk.com - Free Photo Sharing

Reply With Quote
  #3  
Old April 29th, 2002, 08:51 AM
AnthemisCretica AnthemisCretica is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2002
Posts: 8 AnthemisCretica User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
binky: it didnt work, neither
but strange, it must have run ...

any other suggestion or alternative code ?

Reply With Quote
  #4  
Old April 29th, 2002, 09:08 AM
binky's Avatar
binky binky is offline
Gerbil
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Oct 2001
Location: In a Rotastak
Posts: 1,763 binky User rank is Sergeant (500 - 2000 Reputation Level)binky User rank is Sergeant (500 - 2000 Reputation Level)binky User rank is Sergeant (500 - 2000 Reputation Level)binky User rank is Sergeant (500 - 2000 Reputation Level)binky User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 22 h 12 m 52 sec
Reputation Power: 19
In IE you can double click the yellow logo that appears at the bottom left if there's an error. Or go into internet options and switch on 'allways report javascript errors' or something to that effect.

Okay, what I can gather is this:

Using:
document.getElementById(spanname).style.visibility = "visible"

<a href="javascript: makevisible(this.name)" name="span_one"> html </a> -- will not work because IE sees the 'name' attribute as the 'id' attribute so it gets confused, stupid eh?

So, using:
document.getElementById(spanname).style.visibility = "visible"

and:
<a href="javascript: makevisible('span_two')"> jscript </a>

will work, notice the quotation marks though around the parameter being passed, and the lack of the 'name' attribute.

Reply With Quote
  #5  
Old April 29th, 2002, 05:08 PM
mrrichardfeder mrrichardfeder is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Nov 2001
Posts: 765 mrrichardfeder User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 m 45 sec
Reputation Power: 7
Quote:
...will not work because IE sees the 'name' attribute as the 'id' attribute so it gets confused, stupid eh?


Somebody's confused (what a shock).

AnthemisCretica (gotta look that up) -

Any element's id or name is intended to be unique - with the exception of radio buttons, which come in groups. If you name/id more than one element the same, the browser puts the elements in an array - since it can't store them by the same name separately. When it goes looking for the object by name/id, it finds - an array object! Not what you wanted.

And: use *ids*. That's what document.getElementById() returns - a reference to an id'd element. Names are ignored. Other than form elements, the id is poised to become the standard of identifying HTML elements. blinky got the rest right: pass the id as a string (in quotes) and plug it in (at the function end) into the document.getElementById() method; once you've got that object reference, you've got the element, and you can do with it whatever's supported in scripting.

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignJavaScript Development > DHTML, visibility, etc


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
Stay green...Green IT