PDA

View Full Version : Problems with setStyle in my webpage



plaszma
6 Dec 2010, 1:01 AM
Hello,

I have a web page with many divs inside of it.The html and server side code is the following:


<div id="slideshow" >
<%
for i=0 to 660/23
for j=0 to 380/23
Response.Write "<div id=divmic" & i & j & " style='border-style:solid;border-color:black;border-width:1px;width:20px;height:20px;z-index:1;position:absolute;margin-left:" & 23 * i & "px;margin-top:" & 23 * j & "px;'></div>"
next
next
%>
</div>

To manipulate these divs I made the following script in extJS:


Ext.onReady(function(){
var divarray=[];
for(i=0;i<29;i++){
for(j=0;j<17;j++){
var randomdiv={};
randomdiv.id="divmic"+ i.toString() + j.toString();
divarray.push(randomdiv);
}
}
Ext.each(divarray,function(element,index){
Ext.get(element.id).setStyle('border-color','red');
// that doesn't work...
//Ext.get(element.id).setStyle(border-color:'red');....and also that doesn't work...
});
});



In case with Ext.get(element.id).setStyle('border-color','red') it doesn't change the style of divs, but also does not appear a javascript error nowhere.
In the case with Ext.get(element.id).setStyle(border-color:'red') the IE browser shows me an javascript error:
Expected ":"

What's wrong in my code ? Please help me...

Many thanks,

Condor
6 Dec 2010, 1:15 AM
Your second statement doesn't work, because it should be:

Ext.get(element.id).setStyle({'border-color':'red'});

But I don't know why this wouldn't change the border color.

plaszma
6 Dec 2010, 1:22 AM
I try like that...but I still get the javascript error : "Expected ')' ".The most dubious think is that in FF i don't get this error, but also doesn't color the borders...
I usually use the IE browser (version 8) and I think that's enough to support Ext Js...

plaszma
6 Dec 2010, 1:32 AM
Sorry.... my bad.I forgot the "{" and "}".Sory again:(