PDA

View Full Version : How add a radiogroup in a class which the value will be get by a method in a class?


yao
04-18-2006, 07:41 PM
the code as follow:

but if add it to a class, the "id" not allowed.

thanks!


<class name="mydialog" extends="modaldialog" width="400" height="300">
...
<method name="calresult" >
var result;
result = getAttribute("answer");
if (r1.value == result)
...;
else
...;
</method>

<radiogroup id="r1">
<radiobutton value="1">one</radiobutton>
<radiobutton value="2">two</radiobutton>
<radiobutton value="3">three</radiobutton>
<radiobutton value="4">four</radiobutton>
</radiogroup>

vichai
04-19-2006, 12:41 AM
Try to change id to name
Because Id must unique in one application .
So if you have id in class when we create object from that class id will duplicate. :)

yao
04-19-2006, 01:00 AM
I had test it.
but it is not allowed get the value by "name".

vichai
04-19-2006, 01:46 AM
I think that You must use this.r1 instead of r1 alone.

yao
04-19-2006, 02:49 AM
oh!
Yes!

thank you very much!

I am not understanding the difference between the "id" and "name". would you pls give me some advise?

yao
04-19-2006, 03:00 AM
oh!
Yes!

thank you very much!

I am not understanding the difference between the "id" and "name". would you pls give me some advise?

JeffPinkston
04-19-2006, 09:30 AM
Originally posted by yao
I am not understanding the difference between the "id" and "name". would you pls give me some advise? [/B]

name is a local identifier while ID is global

If you give it an ID you can refernece it much easier throughout your page which is why it must be unique. Local referencing requires parent.parent.etc