Sunday, June 2, 2024
 Popular · Latest · Hot · Upcoming
176
rated 0 times [  181] [ 5]  / answers: 1 / hits: 17459  / 12 Years ago, thu, june 14, 2012, 12:00:00

In my javascript file I have the following line:



<div id=mygraph style=width:200px;height:100px;></div>


I'd like to set the width and height values in the style tag from two variables that take their values from the corresponding functions:



var my_width = getWidth();
var my_height = getHeight();


How can I accomplish that? I'm missing the correct syntax. Thank you in advance...


More From » html

 Answers
6

The following assumes that my_height and my_width returned by your functions are plain numbers:



document.getElementById('mygraph').style.height = my_height + px;
document.getElementById('mygraph').style.width = my_width + px;

[#84894] Thursday, June 14, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
jennie

Total Points: 593
Total Questions: 102
Total Answers: 106

Location: Federated States of Micronesia
Member since Fri, Sep 16, 2022
2 Years ago
jennie questions
;