473,388 Members | 1,213 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,388 software developers and data experts.

Assign Variable to Style Property

Hi,

I am desperately trying to assign a variable or rather the return value of a
function to a style property.

document.getElementById("line").style.width=getIns ideWindowWidth();

But it is not working.. and I have no idea why. I can output the return
value of getInsideWindowWidth with alert(getInsideWindowWidth();) and its
working fine..

Thanks for any help!

Regards,
Axel
Jul 23 '05 #1
3 2365


Axel Siebenwirth wrote:

I am desperately trying to assign a variable or rather the return value
of a function to a style property.

document.getElementById("line").style.width=getIns ideWindowWidth();


For a start make sure you set a proper CSS width value e.g.
...style.width = getInsideWindowWidth() + 'px';
If that doesn't help then provide some more details on what the function
returns, what kind of element line is, which browser that fails with.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 23 '05 #2
Martin Honnen wrote:


Axel Siebenwirth wrote:

I am desperately trying to assign a variable or rather the return
value of a function to a style property.

document.getElementById("line").style.width=getIns ideWindowWidth();

For a start make sure you set a proper CSS width value e.g.
...style.width = getInsideWindowWidth() + 'px';


That did it. Thanks!

I did ...style.width = getInsideWindowWidth() + "px";
and that didn't work...

Axel
Jul 23 '05 #3
rw
I think element must be block type - display:block
rw

Axel Siebenwirth wrote:
Hi,

I am desperately trying to assign a variable or rather the return value
of a function to a style property.

document.getElementById("line").style.width=getIns ideWindowWidth();

But it is not working.. and I have no idea why. I can output the return
value of getInsideWindowWidth with alert(getInsideWindowWidth();) and
its working fine..

Thanks for any help!

Regards,
Axel

Jul 23 '05 #4

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

Similar topics

4
by: Eric | last post by:
How can I dynamically assign an event to an element? I have tried : (myelement is a text input) document.getElementById('myelement').onKeyUp = "myfnc(param1,param2,param3)"; ...
8
by: Dennis Marks | last post by:
In the following function: function showMenu(theMenu, theAction) { if (document.getElementById) {document.getElementById(theMenu).style.visibility = theAction;} else {if (document.layers)...
6
by: david | last post by:
I try to use "for" loop to retrieve and assign values in web form. The code is in the following. But it can not be compiled. What I want to do is: txtQ1.Text =...
18
by: joaotsetsemoita | last post by:
Hello everyone, I'm having troubles assigning an onclick event to a cell. Im trying something like cursorPoint.cells.style.cursor = "hand"; cursorPoint.cells.width = "20";...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.