0

Hello take a look at my code then I'll tell you what error I get...

var Top = document.getElementById("topmargin").value;
        var Left = document.getElementById("leftmargin").value;
        var Background_Color = document.getElementById("backgroundcolor").value;
        var Border_Width = document.getElementById("borderwidth").value;
        var Border_Type = document.getElementById("bordertype").value;
        var Border_Color = document.getElementById("bordercolor").value;
        var num = id+1;
        var new_id = "a"+num;
        
        document.getElementById(new_id).style.top = Top;
        document.getElementById(new_id).style.left = Left;
        document.getElementById(new_id).style.backgroundcolor = Background_Color;
        document.getElementById(new_id).style.border = Border_Width+" "+Border_Type+" "+Border_Color;

The element with that id has been created and I still get this error when I try to style it...

Uncaught TypeError: Cannot read property 'style' of null
edit_divjs.js:92
(anonymous function)/PHP%20Projects/StyleStop/#:1
onclick/PHP%20Projects/StyleStop/#:2

My browser is Google Chrome.

2
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by Joe34
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.