Populating select elements dynamically is broken?

RESOLVED DUPLICATE of bug 136885

Status

()

Core
Layout: Form Controls
--
major
RESOLVED DUPLICATE of bug 136885
16 years ago
16 years ago

People

(Reporter: Matias Larsson, Assigned: John Keiser (jkeiser))

Tracking

Trunk
PowerPC
Mac OS X
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(2 attachments)

(Reporter)

Description

16 years ago
This code worked in 0.99, but doesn't work in 1.0rc1;


What it does is populate a drop down (<select>) in another frame when i 
click on some checkboxes.

It's on an intranet, so I cant produce a test case right now. If you need one, 
please let me know and I'll try to create one for you.

---

function updateBasketMenu(checkboxObject, contentID, text, basketID) {
	var basketElement = 
parent.frames['options'].document.getElementById(basketID)
	
	if(checkboxObject.checked) {
		with(basketElement) {
			var menulength = length;
			options[menulength]= new Option(text, contentID);
		}
	}
	else {
		for(var i = 0; i< basketElement.length; i++) {
			if(basketElement.options[i].value == contentID) {
				basketElement.options[i] = null;
				break;
			}
		}
	}
	
	var numImages = basketElement.length - 1; // forget the first row
	var numText;
	switch(numImages) {
		case 0:
			numText = 'No images selected';
			break;
		case 1:
			numText = '1 image selected:';
			break;
		default:
			numText = numImages + ' images selected:';
	}
	basketElement.options[0].text = numText;
}

---

Comment 1

16 years ago
Matias: yes, we'll need a testcase, as reduced as possible.
Could you attach one via the "Create a New Attachment" link above?

Also, do you see any errors in the JavaScript Console?
(be sure to clear it of all previous errors first)

For the time being, reassigning to HTMLFrames. This is not likely
to be a JS Engine bug.
Assignee: rogerl → jkeiser
Component: JavaScript Engine → HTMLFrames
QA Contact: pschwartau → amar
(Reporter)

Comment 2

16 years ago
Created attachment 80361 [details]
Zipped Testcase (a darn ugly one, but hey...)
(Reporter)

Comment 3

16 years ago
Submitted ugly testcase. Upon further inspection, the drop down gets 
populated, but it's visible part doesn't get updated.

OPen up the default.asp.html file.
Click on let's say 3 checkboxes.
The drop down at the bottom still says "No images selected".
Click on the dropdown and you'll see 3 filenames + "3 images selected".
(Assignee)

Updated

16 years ago
Attachment #80361 - Attachment description: Testcase (a darn ugly one, but hey...) → Zipped Testcase (a darn ugly one, but hey...)

Updated

16 years ago
Attachment #80361 - Attachment mime type: application/octet-stream → application/zip

Comment 4

16 years ago
I confirm the testcase behaves as advertised, but it would be better to produce
a *minimized* testcase for the problem, Matias.

Take your tescase and remove everything possible that you can while still
retaining the bug behavior.

Matias, also note that two errors are generated on the JS Console while loading
your testcase: "browser is not defined", and "process_button is not defined".
(Reporter)

Comment 5

16 years ago
Created attachment 83495 [details]
New minimized testcase

Ok, is this new testcase minimized enough for you? ;)

Frames are not involved here. So I changed area to Form Controls. RC2 still has
this bug.
(Reporter)

Updated

16 years ago
Component: HTMLFrames → HTML Form Controls
(Assignee)

Comment 6

16 years ago
Yes, that was enough, thanks.  For future reference, please upload testcases 
as HTML, not zip ... remember, the fewer steps required to use the testcase, 
the quicker bugs get confirmed, investigated, fixed.

Turns out this is a duplicate of bug 136885.

*** This bug has been marked as a duplicate of 136885 ***
Status: UNCONFIRMED → RESOLVED
Last Resolved: 16 years ago
Resolution: --- → DUPLICATE
(Reporter)

Comment 7

16 years ago
Well, I should have tested a trunk build before opening my mouth. It, of 
course, works in the latest trunk.
You need to log in before you can comment on or make changes to this bug.