Javascript Resizing

garrettroyce

Community Support
Community Support
Messages
5,609
Reaction score
250
Points
63
I'm gonna start from scratch, because all I've gotten is errors so far :p

Example html:
Code:
<html>
<body>
<div name="d">Test</div>
<button onclick="resize_div()">Button</button>
</body>
Ok, with this I want to resize the div using the onclick event. That's it. Why can't I do this? :mad:
 

garrettroyce

Community Support
Community Support
Messages
5,609
Reaction score
250
Points
63
Code:
var d = document.getElementsByName("d"); // this works
d.style.height = "100px"; // this does not work, error "style is undefined"
d.style.setAttribute("height","100px"); // this does not work, error "style is undefined"
d.clientHeight = "100px"; // this does not work

That's it. Just trying to keep it basic after hours of pulling my hair out.
Edit:
Found the problem. Left out one of those pesky indexers :p

For example, an array of radio buttons does not have a single style attribute. However, one specific radio button does.

I wish I could close this thread and save myself some ridicule. Lesson learned :)
 
Last edited:

quantum1

New Member
Messages
68
Reaction score
0
Points
0
The link below, with an excerpt below that, seems like it might be addressing the problem you are having.

http://www.webmasterworld.com/forum91/4612.htm

It seems to me that inline elements do not have a height css attribute (unlike block elements, which do have a height css attribute). If you want to use the height attribute, you will have to change the display attribute of thisnav to 'block'.
 
Top