How do I access textField component using javascript in netbeans6.5

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

How do I access textField component using javascript in netbeans6.5

freeborn
I write a simple javascript function as the following

document.getElementById('form1:textField1').value = "hello";

But the textfield shows nothing in netbeans 6.5.
The above code works fine in netbeans 5.5.1.

I already added binding property to both form1 and textfield1.

How to access textfield using javascript in netbeans 6.5 ?
Reply | Threaded
Open this post in threaded view
|

Re: How do I access textField component using javascript in netbeans6.5

freeborn
problem solved.

for someone may not know, In netbeans 6.5 you will have to use the following code

document.getElementById(txt).setProps({value: "hello"});

For more information goto

http://webdev2.sun.com/woodstock-tlddocs/webuijsf/tld-summary.html

hope this help
Reply | Threaded
Open this post in threaded view
|

Re: How do I access textField component using javascript in netbeans6.5

camel8160
i have the same problem, and follow the instructions and it functions if i try the following:

var x = "hello";
document.getElementById('form1:txt1').setProps({value:x});


but i have problems if i use:

var x = document.getElementById('form1:txt2');
document.getElementById('form1:txt1').setProps({value:x});

it shows me in txt1 : "[object HTMLSpanElement]"

thanks

my mail is camel8160@hotmail.com







Reply | Threaded
Open this post in threaded view
|

Re: How do I access textField component using javascript in netbeans6.5

freeborn
You have to code like this

var x = document.getElementById('form1:txt2').getProps().value;
document.getElementById('form1:txt1').setProps({value:x});

good luck.

camel8160 wrote
i have the same problem, and follow the instructions and it functions if i try the following:

var x = "hello";
document.getElementById('form1:txt1').setProps({value:x});


but i have problems if i use:

var x = document.getElementById('form1:txt2');
document.getElementById('form1:txt1').setProps({value:x});

it shows me in txt1 : "[object HTMLSpanElement]"

thanks

my mail is camel8160@hotmail.com






Reply | Threaded
Open this post in threaded view
|

Re: How do I access textField component using javascript in netbeans6.5

pscamara
In reply to this post by freeborn
I got this simple page:

        <webuijsf:page id="page1">
            <webuijsf:html id="html1">
                <webuijsf:head id="head1">
                <webuijsf:script>
                    function timeIt() {
                       var x = "60:00";
                       document.getElementById('form1:clock').setProps({value:x});
                    }
                </webuijsf:script>
                </webuijsf:head>
                <webuijsf:body id="body1" onLoad="timeIt()" style="-rave-layout: grid">
                    <webuijsf:form id="form1">
                        <webuijsf:textField columns="5" id="clock"/>                       
                    </webuijsf:form>
                </webuijsf:body>
            </webuijsf:html>
        </webuijsf:page>

But javascript never works!

Message: 'document.getElementById(...)' is null or not an object

Any help?