473,804 Members | 2,173 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Dynamic select lists using optgroups again - without frameworks

Hi group!

After my first post a few days ago and your advice not to use the
Prototype Framework (which indeed was a good idea! ;-)) I rewrote my
script for dynamic select lists.
This is what it looks like now: http://pastie.caboo.se/140953 (I know
it's messy, but I don't see another way)

Let me explain how it works in short.
First it get's all select elements with classes dynamic_select and
parent in one array and the related child elements with classes
dynamic_select and child in another.

Then I loop through them and extract the options into
grouped_options _store and store the index as the rel attribute of the
parent element.

When the value now changes it determines the text of the selected
parent item and looks for an optgroup with that text as a label.
If it can find one it inserts thoses options from grouped_options _store
into the second list.

Unfortunately I'm having the exact same problem as with the old
version, it works fine in Firefox and Safari but when I select a parent
item in the first list the second list just doesn't change.
It displays the unformatted optgroups from the markup.

Here is a live example again:
http://pascal.hacksrus.net/dev/sandbox.html

I hope you can help me out this time!
Many thanks in advance

Pascal

Jan 19 '08 #1
3 1718
Okay, sorry, I assume that was a stupid beginner's mistake.
IE apparently doesn't support addEventListene r but has attachEvent.

I fixed the problem that the stuff didn't get loaded like this:
if (window.addEven tListener) {
window.addEvent Listener('load' , initDynamicSele cts, false);
} else {
window.attachEv ent('onload', initDynamicSele cts);
}

There are some other problems still, but I hope I can sort them out on my own.

Regards

Pascal

Jan 19 '08 #2
Okay, I do have one more question.
How can I determine whether to use e.target or e.srcElement (IE)?

This throws an error in IE (target is 'null' or not an object):

if (e.target) {
target = e.target
} else {
target = e.srcElement;
}
Regards

Pascal

Jan 19 '08 #3
Pascal Ehlert wrote:
>understood that JS shouldn't be treated as a way to quickly add
some eyecandy to your page but wants to be understood.
I promise to give my best to understand it! :-)

I understand also that pencils should not be used to clean your ears of
wax, but when wax and pencils is all you have, it works well enough ;-)

-- Pascal Ehlert
Jan 20 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
7661
by: Ryan McGeary | last post by:
In a <select> drop-down, the onchange event isn't called when scrolling through the dropdown using the mouse-wheel and when crossing over a new <optgroup>. Using the example below, notice how the onchange event isn't called when mouse wheel scrolling between A3 and B1, but it works properly when scrolling between A1 and A2. E.g. ------------------------------------------
13
2900
by: mr_burns | last post by:
hi, is it possible to change the contents of a combo box when the contents of another are changed. for example, if i had a combo box called garments containing shirts, trousers and hats, when the user selects shirts another combo box called 'size' would contain sizes in relation to shirts (ie. chest/neck size). the same would occur for trousers and hats. when the user selects an option in the garment combo box, the options available...
3
15626
by: Stewart | last post by:
Dear comp.lang.javascript, I have more than once wanted to manipulate the contents of select boxes dynamically, whilst the boxes contain <optgroup> tags. Manipulation of a select box containing only <option> tags is fairly easy and there is plenty of material on the net to assist with this. However, I have searched long and found the material on the subject of <optgroup> to be sparse, with a few posts here & there, but basically you're...
2
1985
by: taras.di | last post by:
Hi everyone, I've been reading up on how to create a drop down box who's context is dynamically produced based on the value of a previous select box. I've read a lot about some of the browsers not properly readjusting the width of a dynamically produced drop down box, and some browsers having problems adjusting the height and widths (most notably NN). Most solutions involve manually refreshing the browser window and/or padding the...
0
2074
by: Pascal Costanza | last post by:
Dynamic Languages Day @ Vrije Universiteit Brussel ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Monday, February 13, 2006, VUB Campus Etterbeek The VUB (Programming Technology Lab, System and Software Engineering Lab), ULB (deComp) and the Belgian Association for Dynamic Languages (BADL) are very pleased to invite you to a whole day of presentations about the programming languages Self, Smalltalk and Common Lisp by experts in...
11
3063
by: toton | last post by:
Hi, I have little confusion about static memory allocation & dynamic allocation for a cluss member. I have class like class Bar{ public: explicit Bar(){ cout<<"bar default"<<endl; }
16
13632
by: Brian D | last post by:
I have a multiple select list that is created dynamically based on a previous selection on an asp page. The first thing I do is to clear the curent option list by document.form1.itemcross.length = 0; The only problem is that it leaves the optgroups. How do I also get rid of the optgroups? Thanks
1
5083
by: madflytom | last post by:
Hello, I'm trying to move the options of one select list to another select list. The "source" select list is divided into optgroups, and the "target" select list is not. I want to somehow keep track of the moved option's optgroup, so that if I remove it from the "target" select list, it moves back into it's respective optgroup in the "source" select list. I have things moving back and forth, but I'm not sure how to handle the optgroup...
6
1826
by: Pascal Ehlert | last post by:
Hi group! I was trying to build a JS solution for related select lists (child lists gets populated depending on the value selected in parent list), which uses no Ajax and is still "usable" in an environment with JS disabled. 
I have done this with the Low Pro framework which basically just registers event handlers on certain elements chosen by CSS selectors. This is the result: 
http://pastie.caboo.se/136818 The initialize function...
0
9711
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10595
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10343
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10088
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7633
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6862
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5529
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5668
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3831
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.