Even with your code it still throws an error in IE. because in IE none of the songs get added to sel2. It still add options to sel2 in Firefox and opera.
Also I worry if the global vars s1 and s2 are not being used.
Even with your code it still throws an error in IE. because in IE none of the songs get added to sel2. It still add options to sel2 in Firefox and opera.
Also I worry if the global vars s1 and s2 are not being used.
My code works fine in IE:
http://home.comcast.net/~jscheuer1/s...ve_options.htm
But you aren't moving, you're copying. So, where I have (slightly simplified over the previous version, we don't have to removeChild, browsers do it automatically):
A companion function to copy options could be:Code:function moveOption(s1, s2, opt){ s1 = document.getElementById(s1); s2 = document.getElementById(s2); opt = opt || s1.options[s1.options.selectedIndex]; if(opt.value){ s2.appendChild(opt); } }
Code:function copyOption(s1, s2, opt){ s1 = document.getElementById(s1); s2 = document.getElementById(s2); opt = opt || s1.options[s1.options.selectedIndex]; if(opt.value){ s2.appendChild(opt.cloneNode(true)); } }
- John________________________
Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate
yeah I should just use that. I have no idea why my script wasn't working in IE.
I'll ask more questions if I have any problems.
From what you've told me so far, this:
http://home.comcast.net/~jscheuer1/s...te_options.htm
might be very close to what you're looking for.
Notes: I added error checking for selects that are out of range and to prevent duplicates. The clear function ignores the first option in the select, but doesn't have to. The functions used have also other capabilities.
- John________________________
Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate
Yes, but are functions 1,2 and 3 purely optional. Can the script work with out them. I ask because I may want to add more select list or change it so select list with a particular className can send their options to sel2(sel3 in your code).
No. But that shouldn't stop you from using the code as you see fit.
If you look over the code, it should be fairly obvious what each function does. If you have specific questions, feel free.
In general:
- manipOption() is the centerpiece. It does the main work of either copying or moving an option depending upon how it's invoked.
- manipOption.noDupe() ensures that when copying or moving an option to another select, that the option's value is not already represented by another option already in the target select.
- manipOption.inRange() determines whether or not the option to be moved exists insofar as is it a specific option element, and if not, if it is represented by an index of the from select's options, if that is a valid index for the options in that select.
- manipOption.multiCopy() is a front end for manipOption() to get it to handle selects with the multiple attribute set visa vis allowing more than one option from a multiple select to be copied at a time, and at the same time to allow two from selects to be copied from at one time.
- manipOption.clear() is pretty much standalone except that to conserve the global namespace it uses the main manipOption() object's namespace. What it does is optionally remove all options from a select, or only the selected one(s), depending upon how it's invoked. In it you will see:
Because of that, it will always skip removing the first option. If that 0 is changed to -1, then the first option will also be removed if it qualifies for removal.Code:for (var i = sel.options.length - 1; i >0; --i){
- John________________________
Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate
I'm getting the error manipOption is not defined.
Line: 1
what do you think is happening?
Sounds like either a syntax error or typo, or you failed to include it in your version. What's the link to your current version?
Please post a link to a page on your site that contains the problematic code so we can check it out.
- John________________________
Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate
it's off line so it's better that I give you the source.
there are a lot of things commented out because I'm planning to do a some other things. functionally I'm wondering if it would be a good idea to add a stop function to the media player. I haven't decided what to do. but anyway here is the code. I probably made some dumb error in the HTML.
it was so large I have to attach it.
I'll say. It's unwise to use HTML comment tags (there are a lot of things commented out<!--or-->) inside a script tag. They can be used, but their logic and significance is different than when used in normal HTML. Their main reason inside a script tag though is to hide the script code from older browsers. This is no longer needed, and in the future may cause the script code to be skipped. So all comments within a script block should be javascript comments (//for 'from here to the end of the line' or/* */for 'ignore what's between').
That said, simply removing:
from line #151 seems to satisfy IE, while Firefox doesn't have a problem with it either way.Code:-->
Once you do that, both browsers recognize the 'missing' function. But you still have a problem.
You originally asked to do this using document.getElementById(), but there are no elements with the id of sel1, sel2, or sel3. There are elements with those names. So just add here (and similar for the other two):
Back in business!Code:<div id="slider"> <select name="sel1"id="sel1"size="13" multiple="multiple" oncha . . .
- John________________________
Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate
Bookmarks