Closed Bug 80399 Opened 23 years ago Closed 23 years ago

Radiogroup not able to get the value attribute of the default radio item

Categories

(Core :: XUL, defect, P3)

x86
Windows NT
defect

Tracking

()

RESOLVED FIXED
mozilla0.9.6

People

(Reporter: racham, Assigned: bugzilla)

Details

Attachments

(3 files)

Radiogroup widget is not able to get the value of the default radio item in 
the group when queried for Radiogroup.value

Here is the situation

in xul : 
<radiogroup id="foo">
  <radio group="foo" value="bar1" label="test1" checked="true"/>
  <radio group="foo" value="bar2" label="test2"/>
</radiogroup>

in js (say in onInt()) :

when I do 

var serverTypeRadioGroup = document.getElementById("foo");
dump("default value = " + serverTypeRadioGroup.value + "\n");

I would expect it to print 'bar1' as that is the value of the default radio item 
(as checked attribute is set to true there).

instead, I have to do some thing like this for that to happen

serverTypeRadioGroup.value = 
serverTypeRadioGroup.selectedItem.getAttribute("value");
dump("default value = " + serverTypeRadioGroup.value + "\n");
Withtout the hack I mentioned in the previous update, radiogroup waits for user 
to make explicit selection of one of radio items to give a valid value for 
radiogroup.value query.
Why don't you use something like this:

var serverTypeRadioGroup = document.getElementById("foo").selectedItem;
dump("default value = " + serverTypeRadioGroup.value + "\n");

'value' is a method so you don't need element.getAttribute('value') just use
element.value for it.
Attached file small testcase/example
Seems busted.  Ben, you can whip up a fix for this in no time.
Assignee: hyatt → ben
I have a patch for this, but should this be done in radio.xml or radioBindings.xml ?
if i apply the patch to /xpfe/global/resources/content/bindings/radio.xml then
this problem is fixed. Will make a diff -u after cvs update. brb.
Ben should sr... I don't remember why you would need this...

Comment on attachment 34295 [details] [diff] [review]
apply this patch and the above testcase will show bar2

sr=ben@netscape.com
Attachment #34295 - Flags: superreview+
Status: NEW → ASSIGNED
Target Milestone: --- → mozilla1.0
patch, -> .9.9
Priority: -- → P3
Target Milestone: mozilla1.0 → mozilla0.9.9
-->me
Assignee: ben → blakeross
Status: ASSIGNED → NEW
Target Milestone: mozilla0.9.9 → mozilla0.9.6
Fixed.
Status: NEW → RESOLVED
Closed: 23 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: