myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Legolas Woodland <legola...@gmail.com>
Subject Re: [OT]Problem with accessing form Element using javaScript
Date Fri, 31 Mar 2006 05:56:39 GMT
Hi
thank you for reply.
forceId is just for myfaces , and for now i am not using myfaces.
I change that to what you said and i still get the same error from 
javascript Console


Error: staticText8 has no properties
Source File: http://localhost:28081/pluto/portal/Publisher/.......
Line: 306

Thank you for the help

Gerald Müllan wrote:
> Hi,
>
> stupid thing, but try it out with:
>
> var testValue = document.getElementById("form1:statictext8");
> testvalue.style = "...";
>
> I am more or less sure that this is the problem. In js you can not
> concat method calls in every case.
>
> Apart from that, getting the dom element through the generated id is
> not best practice.
> Use forceId="true" in the jsp tag to be sure that you can get the id
> on client in a predictable manner.
>
> cheers,
>
> Gerald
>
> On 3/31/06, Legolas Woodland <legolas.w@gmail.com> 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 ?
>>
>> Thanks
>>
>>     
>
>
> --
> Gerald Müllan
> Schelleingasse 2/11
> 1040 Vienna, Austria
> 0043 699 11772506
> Bierbrauen@gmail.com
>
>   


Mime
View raw message