You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Laurie Harper <la...@holoweb.net> on 2006/04/01 08:28:35 UTC
Re: [OT]Problem with accessing form Element using javaScript
Legolas Woodland wrote:
> Hi
> thank you for reading my post.
> I have this problem in my web application :
> generated html which i view in my browser has this :
>
> [code]
>
> <span id="form1:staticText8" style="border-width: 1px; border-style:
> solid; border-color: rgb(0, 0, 0) rgb(0, 0, 0) rgb(0, 0, 0) rgb(0, 0,
> 0); height: 15px; left: 23px; top: 392px; position: absolute; width:
> 145px">My test Value</span>
> [/code]
>
> In my java Script function i have:
>
> [code]
> function setNewColors(obj)
> {
> if(obj=='Yellow'){
> document.getElementById("form1:statictext8").style =" left: 25px; top:
> 383px; position: absolute; width: 143px; border-width: 1px;
> border-style: solid; border-color:#fdffca; background-color:#fdffca;
> color: #000000;";
> }
> }
> [/code]
>
> i trigger the color change function in :
> [code]
> <select style="left: 264px; top: 240px; position: absolute; width:
> 288px" class="MnuStd" id="form1:dropDown1" name="form1:dropDown1"
> size="1"
> onchange="setNewColors(this.value);dropDown_changed('form1:dropDown1');
> return false;">
> [/code]
>
> When i select yellow from the drop down box , it call color change but
> in javaScript console of FireFox i get an error like :
>
> [code]
> Error: document.getElementById("form1:statictext8") has no properties
> Source File: http://localhost:28081/pluto/portal/Publisher/......
> Line: 299
> [/code]
>
>
> can some one please tell me what is my mistake ?
You can't say elem.style = "..." in Javascript. Style isn't a
string-valued property, it's a 'special' accessor for an object with CSS
style properties. You need something more like
with(document.getElementById("form1:statictext8").style) {
left = '25px';
top = '383px';
...
}
L.
Re: [OT]Problem with accessing form Element using javaScript
Posted by Legolas Woodland <le...@gmail.com>.
Martin Marinschek wrote:
> Co-ol!
>
> Martin tries to learn one thing a day, thanks Gerald for helping him
> out with today. style.cssText, a-ha.
>
> regards,
>
> Martin
>
> On 4/1/06, Gerald Müllan <bi...@gmail.com> wrote:
>
>> I believe you can also access the style attribute over:
>>
>> elem.style.cssText = "...";
>>
>> this should also work.
>>
>> cheers,
>>
>> Gerald
>>
>> On 4/1/06, Laurie Harper <la...@holoweb.net> wrote:
>>
>>> Legolas Woodland wrote:
>>>
>>>> Hi
>>>> thank you for reading my post.
>>>> I have this problem in my web application :
>>>> generated html which i view in my browser has this :
>>>>
>>>> [code]
>>>>
>>>> <span id="form1:staticText8" style="border-width: 1px; border-style:
>>>> solid; border-color: rgb(0, 0, 0) rgb(0, 0, 0) rgb(0, 0, 0) rgb(0, 0,
>>>> 0); height: 15px; left: 23px; top: 392px; position: absolute; width:
>>>> 145px">My test Value</span>
>>>> [/code]
>>>>
>>>> In my java Script function i have:
>>>>
>>>> [code]
>>>> function setNewColors(obj)
>>>> {
>>>> if(obj=='Yellow'){
>>>> document.getElementById("form1:statictext8").style =" left: 25px; top:
>>>> 383px; position: absolute; width: 143px; border-width: 1px;
>>>> border-style: solid; border-color:#fdffca; background-color:#fdffca;
>>>> color: #000000;";
>>>> }
>>>> }
>>>> [/code]
>>>>
>>>> i trigger the color change function in :
>>>> [code]
>>>> <select style="left: 264px; top: 240px; position: absolute; width:
>>>> 288px" class="MnuStd" id="form1:dropDown1" name="form1:dropDown1"
>>>> size="1"
>>>> onchange="setNewColors(this.value);dropDown_changed('form1:dropDown1');
>>>> return false;">
>>>> [/code]
>>>>
>>>> When i select yellow from the drop down box , it call color change but
>>>> in javaScript console of FireFox i get an error like :
>>>>
>>>> [code]
>>>> Error: document.getElementById("form1:statictext8") has no properties
>>>> Source File: http://localhost:28081/pluto/portal/Publisher/......
>>>> Line: 299
>>>> [/code]
>>>>
>>>>
>>>> can some one please tell me what is my mistake ?
>>>>
>>> You can't say elem.style = "..." in Javascript. Style isn't a
>>> string-valued property, it's a 'special' accessor for an object with CSS
>>> style properties. You need something more like
>>>
>>> with(document.getElementById("form1:statictext8").style) {
>>> left = '25px';
>>> top = '383px';
>>> ...
>>> }
>>>
>>>
>>> L.
>>>
>>>
>>>
>> --
>> Gerald Müllan
>> Schelleingasse 2/11
>> 1040 Vienna, Austria
>> 0043 699 11772506
>> Bierbrauen@gmail.com
>>
>>
>
>
> --
>
> http://www.irian.at
>
> Your JSF powerhouse -
> JSF Consulting, Development and
> Courses in English and German
>
> Professional Support for Apache MyFaces
>
>
Hi
Thank you all for helping me solve this problem.
I have 3 mistake :
1-I should declare a variable and put the Textfield into it , then i can
access that object attribute
2-JavaScript is case sensitive for this case and other case too , so i
should use form1:staticText8
3-I should not use style and i should use , style.cssText
Thank you all.
Re: [OT]Problem with accessing form Element using javaScript
Posted by Gerald Müllan <bi...@gmail.com>.
> Martin tries to learn one thing a day, thanks Gerald for helping him
> out with today. style.cssText, a-ha.
I hope it`s a trueness a-ha session-learned for today :)
cheers,
Gerald
>
> regards,
>
> Martin
>
> On 4/1/06, Gerald Müllan <bi...@gmail.com> wrote:
> > I believe you can also access the style attribute over:
> >
> > elem.style.cssText = "...";
> >
> > this should also work.
> >
> > cheers,
> >
> > Gerald
> >
> > On 4/1/06, Laurie Harper <la...@holoweb.net> wrote:
> > > Legolas Woodland wrote:
> > > > Hi
> > > > thank you for reading my post.
> > > > I have this problem in my web application :
> > > > generated html which i view in my browser has this :
> > > >
> > > > [code]
> > > >
> > > > <span id="form1:staticText8" style="border-width: 1px; border-style:
> > > > solid; border-color: rgb(0, 0, 0) rgb(0, 0, 0) rgb(0, 0, 0) rgb(0, 0,
> > > > 0); height: 15px; left: 23px; top: 392px; position: absolute; width:
> > > > 145px">My test Value</span>
> > > > [/code]
> > > >
> > > > In my java Script function i have:
> > > >
> > > > [code]
> > > > function setNewColors(obj)
> > > > {
> > > > if(obj=='Yellow'){
> > > > document.getElementById("form1:statictext8").style =" left: 25px; top:
> > > > 383px; position: absolute; width: 143px; border-width: 1px;
> > > > border-style: solid; border-color:#fdffca; background-color:#fdffca;
> > > > color: #000000;";
> > > > }
> > > > }
> > > > [/code]
> > > >
> > > > i trigger the color change function in :
> > > > [code]
> > > > <select style="left: 264px; top: 240px; position: absolute; width:
> > > > 288px" class="MnuStd" id="form1:dropDown1" name="form1:dropDown1"
> > > > size="1"
> > > > onchange="setNewColors(this.value);dropDown_changed('form1:dropDown1');
> > > > return false;">
> > > > [/code]
> > > >
> > > > When i select yellow from the drop down box , it call color change but
> > > > in javaScript console of FireFox i get an error like :
> > > >
> > > > [code]
> > > > Error: document.getElementById("form1:statictext8") has no properties
> > > > Source File: http://localhost:28081/pluto/portal/Publisher/......
> > > > Line: 299
> > > > [/code]
> > > >
> > > >
> > > > can some one please tell me what is my mistake ?
> > >
> > > You can't say elem.style = "..." in Javascript. Style isn't a
> > > string-valued property, it's a 'special' accessor for an object with CSS
> > > style properties. You need something more like
> > >
> > > with(document.getElementById("form1:statictext8").style) {
> > > left = '25px';
> > > top = '383px';
> > > ...
> > > }
> > >
> > >
> > > L.
> > >
> > >
> >
> >
> > --
> > Gerald Müllan
> > Schelleingasse 2/11
> > 1040 Vienna, Austria
> > 0043 699 11772506
> > Bierbrauen@gmail.com
> >
>
>
> --
>
> http://www.irian.at
>
> Your JSF powerhouse -
> JSF Consulting, Development and
> Courses in English and German
>
> Professional Support for Apache MyFaces
>
--
Gerald Müllan
Schelleingasse 2/11
1040 Vienna, Austria
0043 699 11772506
Bierbrauen@gmail.com
Re: [OT]Problem with accessing form Element using javaScript
Posted by Martin Marinschek <ma...@gmail.com>.
Co-ol!
Martin tries to learn one thing a day, thanks Gerald for helping him
out with today. style.cssText, a-ha.
regards,
Martin
On 4/1/06, Gerald Müllan <bi...@gmail.com> wrote:
> I believe you can also access the style attribute over:
>
> elem.style.cssText = "...";
>
> this should also work.
>
> cheers,
>
> Gerald
>
> On 4/1/06, Laurie Harper <la...@holoweb.net> wrote:
> > Legolas Woodland wrote:
> > > Hi
> > > thank you for reading my post.
> > > I have this problem in my web application :
> > > generated html which i view in my browser has this :
> > >
> > > [code]
> > >
> > > <span id="form1:staticText8" style="border-width: 1px; border-style:
> > > solid; border-color: rgb(0, 0, 0) rgb(0, 0, 0) rgb(0, 0, 0) rgb(0, 0,
> > > 0); height: 15px; left: 23px; top: 392px; position: absolute; width:
> > > 145px">My test Value</span>
> > > [/code]
> > >
> > > In my java Script function i have:
> > >
> > > [code]
> > > function setNewColors(obj)
> > > {
> > > if(obj=='Yellow'){
> > > document.getElementById("form1:statictext8").style =" left: 25px; top:
> > > 383px; position: absolute; width: 143px; border-width: 1px;
> > > border-style: solid; border-color:#fdffca; background-color:#fdffca;
> > > color: #000000;";
> > > }
> > > }
> > > [/code]
> > >
> > > i trigger the color change function in :
> > > [code]
> > > <select style="left: 264px; top: 240px; position: absolute; width:
> > > 288px" class="MnuStd" id="form1:dropDown1" name="form1:dropDown1"
> > > size="1"
> > > onchange="setNewColors(this.value);dropDown_changed('form1:dropDown1');
> > > return false;">
> > > [/code]
> > >
> > > When i select yellow from the drop down box , it call color change but
> > > in javaScript console of FireFox i get an error like :
> > >
> > > [code]
> > > Error: document.getElementById("form1:statictext8") has no properties
> > > Source File: http://localhost:28081/pluto/portal/Publisher/......
> > > Line: 299
> > > [/code]
> > >
> > >
> > > can some one please tell me what is my mistake ?
> >
> > You can't say elem.style = "..." in Javascript. Style isn't a
> > string-valued property, it's a 'special' accessor for an object with CSS
> > style properties. You need something more like
> >
> > with(document.getElementById("form1:statictext8").style) {
> > left = '25px';
> > top = '383px';
> > ...
> > }
> >
> >
> > L.
> >
> >
>
>
> --
> Gerald Müllan
> Schelleingasse 2/11
> 1040 Vienna, Austria
> 0043 699 11772506
> Bierbrauen@gmail.com
>
--
http://www.irian.at
Your JSF powerhouse -
JSF Consulting, Development and
Courses in English and German
Professional Support for Apache MyFaces
Re: [OT]Problem with accessing form Element using javaScript
Posted by Gerald Müllan <bi...@gmail.com>.
I believe you can also access the style attribute over:
elem.style.cssText = "...";
this should also work.
cheers,
Gerald
On 4/1/06, Laurie Harper <la...@holoweb.net> wrote:
> Legolas Woodland wrote:
> > Hi
> > thank you for reading my post.
> > I have this problem in my web application :
> > generated html which i view in my browser has this :
> >
> > [code]
> >
> > <span id="form1:staticText8" style="border-width: 1px; border-style:
> > solid; border-color: rgb(0, 0, 0) rgb(0, 0, 0) rgb(0, 0, 0) rgb(0, 0,
> > 0); height: 15px; left: 23px; top: 392px; position: absolute; width:
> > 145px">My test Value</span>
> > [/code]
> >
> > In my java Script function i have:
> >
> > [code]
> > function setNewColors(obj)
> > {
> > if(obj=='Yellow'){
> > document.getElementById("form1:statictext8").style =" left: 25px; top:
> > 383px; position: absolute; width: 143px; border-width: 1px;
> > border-style: solid; border-color:#fdffca; background-color:#fdffca;
> > color: #000000;";
> > }
> > }
> > [/code]
> >
> > i trigger the color change function in :
> > [code]
> > <select style="left: 264px; top: 240px; position: absolute; width:
> > 288px" class="MnuStd" id="form1:dropDown1" name="form1:dropDown1"
> > size="1"
> > onchange="setNewColors(this.value);dropDown_changed('form1:dropDown1');
> > return false;">
> > [/code]
> >
> > When i select yellow from the drop down box , it call color change but
> > in javaScript console of FireFox i get an error like :
> >
> > [code]
> > Error: document.getElementById("form1:statictext8") has no properties
> > Source File: http://localhost:28081/pluto/portal/Publisher/......
> > Line: 299
> > [/code]
> >
> >
> > can some one please tell me what is my mistake ?
>
> You can't say elem.style = "..." in Javascript. Style isn't a
> string-valued property, it's a 'special' accessor for an object with CSS
> style properties. You need something more like
>
> with(document.getElementById("form1:statictext8").style) {
> left = '25px';
> top = '383px';
> ...
> }
>
>
> L.
>
>
--
Gerald Müllan
Schelleingasse 2/11
1040 Vienna, Austria
0043 699 11772506
Bierbrauen@gmail.com