DIV tag mimic for CLASS object

Author Message
u jayakodi

  • Total Posts : 17
  • Scores: 0
  • Reward points : 0
  • Joined: 9/30/2010
  • Status: offline
DIV tag mimic for CLASS object Wednesday, December 15, 2010 6:48 PM (permalink)
0
jayakodiu@yahoo.com
DIV tag mimic for CLASS object

A DIV tag does not show anything unless the background color and width or height are defined; this makes it an ideal candidate to be an invisible 'container' to hold info by setting attributes of our liking. The following code for a DIV tag mimics a CLASS object, which is otherwise quite complex:
 
<SCRIPT LANGUAGE="VBScript">
'The routine to create the 'rectangle class' and properties
sub addrec(sx,sy,w,h)
set ele=document.body.appendchild(document.createelement("DIV"))
'add properties to our rectangle object
ele.setattribute "name","rectangle"
ele.setattribute "sx",sx
ele.setattribute "sy",sy
ele.setattribute "w",w
ele.setattribute "h",h
area=w*h
ele.setattribute "area",area
perimeter=2*(w+h)
ele.setattribute "peri",perimeter
momtofinertia=w*h^3/12
ele.setattribute "momin",momtofinertia
end sub
'test the class creating 5 rectangles
addrec 100,100,10,20
addrec 100,100,20,20
addrec 100,100,30,20
addrec 100,100,40,20
addrec 100,100,50,20
set rn=document.getelementsbytagname("DIV")
n=rn.length-1
for i=0 to n
nam=rn(i).getattribute("name")
if nam="rectangle" then msgbox rn(i).momin
next
'we can have an attribute 'index' or have a parent DIV to hold our objects as children.
</SCRIPT>
 
 
#1

    Online Bookmarks Sharing: Share/Bookmark

    Jump to:

    Current active users

    There are 0 members and 1 guests.

    Icon Legend and Permission

    • New Messages
    • No New Messages
    • Hot Topic w/ New Messages
    • Hot Topic w/o New Messages
    • Locked w/ New Messages
    • Locked w/o New Messages
    • Read Message
    • Post New Thread
    • Reply to message
    • Post New Poll
    • Submit Vote
    • Post reward post
    • Delete my own posts
    • Delete my own threads
    • Rate post

    2000-2012 ASPPlayground.NET Forum Version 3.9