f



options.selected on select multiple

Hi !

I have a problem with Internet Explorer that I really can't explain.
If anyone can find a solution to this, I congratulate you...

I'm trying to have a script dynamically select all (or some) of the
options in a select field.  It won't work, it will only select one
option at a time...

While I was trying to debug, I realized that if I put an alert before
the instructions, it will work !!!

I've been able to recreate the problem in a simple html file...  try
this !

First run the file as it is here... one option is selected.
Then, uncomment the alert("test"); line and run it again...  all
options are selected !!!!!!!

Thanks for any help...

---

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
	<title>Untitled</title>
</head>

<body>
    <span id="itGoesHere"></span>
</body>
</html>
<script type="text/javascript">
    function mySelectField(optionsToCreate) {
        this.fieldReference = window.document.createElement("select");
        this.fieldReference.id = "myselect";
        this.fieldReference.multiple = true;
        this.fieldReference.size = 10;

window.document.getElementById("itGoesHere").appendChild(this.fieldReference);

        for (var i=0; i < optionsToCreate.length; i++) {

this.fieldReference.options[this.fieldReference.options.length] = new
Option(optionsToCreate[i][1], optionsToCreate[i][0]);
        }
    }
        mySelectField.prototype.selectAll = function() {
            for (var i=0; i < this.fieldReference.options.length; i++)
{
                this.fieldReference.options[i].selected = true;
            }
        }

    var myField = new mySelectField([["1", "Test - 1"],["2", "Test -
2"],["3", "Test - 3"],["4", "Test - 4"],["5", "Test - 5"]]);
    //alert("test");
    myField.selectAll();
</script>

0
7/28/2006 8:54:24 PM
comp.lang.javascript 38370 articles. 2 followers. javascript4 (1315) is leader. Post Follow

4 Replies
513 Views

Similar Articles

[PageSpeed] 5

        Roughly I'd say is a runtime issue in IE, so, do the appendChild() first, and
the .multiple=true; afterwards, as for selecting options, new Option() constructor has 4
optional arguments, the last 2 are also boolean, true/false if its default state is to
selected , and true/false for current state to selected, which you can use when making the
option, instead of looping through.

                                        Danny


0
Danny
7/29/2006 5:52:33 AM
Hmmm.. nope !  I've tried both Ideas and it did nothing good...

I'm wondering if there might be something I could put instead of an
alert that would cause it to magically work without requiring user
input...

0
DBoy001
7/31/2006 2:39:10 PM
Found an answer on another thread of this forum (aparently, lots of
people have experienced this).  If I create the select using this
format, it'll work :

this.fieldReference = window.document.createElement("<select
name=\"myselect\" id=\"myselect\" multiple=\"multiple\"
size=\"10\"></select>");

0
DBoy001
7/31/2006 3:10:20 PM
DBoy001 wrote:
> Hi !
>
> I have a problem with Internet Explorer that I really can't explain.
> If anyone can find a solution to this, I congratulate you...
>
> I'm trying to have a script dynamically select all (or some) of the
> options in a select field.  It won't work, it will only select one
> option at a time...
>
> While I was trying to debug, I realized that if I put an alert before
> the instructions, it will work !!!
>
> I've been able to recreate the problem in a simple html file...  try
> this !
>
> First run the file as it is here... one option is selected.
> Then, uncomment the alert("test"); line and run it again...  all
> options are selected !!!!!!!
>
> Thanks for any help...
>
> ---
>
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
>
> <html>
> <head>
> 	<title>Untitled</title>
> </head>
>
> <body>
>     <span id="itGoesHere"></span>
> </body>
> </html>
> <script type="text/javascript">
>     function mySelectField(optionsToCreate) {
>         this.fieldReference = window.document.createElement("select");
>         this.fieldReference.id = "myselect";
>         this.fieldReference.multiple = true;
>         this.fieldReference.size = 10;
>
> window.document.getElementById("itGoesHere").appendChild(this.fieldReference);
>
>         for (var i=0; i < optionsToCreate.length; i++) {
>
> this.fieldReference.options[this.fieldReference.options.length] = new
> Option(optionsToCreate[i][1], optionsToCreate[i][0]);
>         }
>     }
>         mySelectField.prototype.selectAll = function() {
>             for (var i=0; i < this.fieldReference.options.length; i++)
> {
>                 this.fieldReference.options[i].selected = true;
>             }
>         }
>
>     var myField = new mySelectField([["1", "Test - 1"],["2", "Test -
> 2"],["3", "Test - 3"],["4", "Test - 4"],["5", "Test - 5"]]);
>     //alert("test");
>     myField.selectAll();
> </script>
Kindof lame but, putting the last line in a timeout for a delay made it
work on mine.
setTimeout("myField.selectAll();",10);

0
Paul
7/31/2006 6:09:27 PM
Reply:

Similar Artilces:

select.select()
please help me.. what does the following line do? read_sockets,write_sockets,error_sockets = select.select(CONNECTION_LIST,[],[]) In article <b8d42424-e0ab-4595-9c87-25e5c1b53349@googlegroups.com>, Bhanu Karthik <bhanukarthik2002@gmail.com> wrote: > please help me.. what does the following line do? > > read_sockets,write_sockets,error_sockets = > select.select(CONNECTION_LIST,[],[]) This is a little tricky. First,read the docs at http://docs.python.org/2/library/select.html. There's a lot of complicated stuff there, but just concentrate on the description of the select.select() call for now. Imagine a process which has a lot of network connections open. A great example would be something like a MUD (Multi User Dungeon). You've got one server process(*) and a bunch of clients which have all made TCP connections over individual sockets. Each client will be sending commands asynchronously, and the server needs to handle this. You need some way to figure out which of those sockets have something that's been sent to you (which you need to process) and which are just sitting idle. That's where select() comes in. It gives you a way to say, "Here's a list of sockets. Sleep until one of them has something available for me to read, and let me know which one." One bit of complication is that you can also check for sockets which are ready to be written on, and sockets which ...

Select from (select)
This is a multi-part message in MIME format. ------_=_NextPart_001_01C43384.9C3B5D61 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Is it possible to do a select from a select statement in Informix? Ex: Select Customer from (Select Customer, sum(invoiced_amt) as total_spent from Customers group by Customer) where total_spent > 1000 ------_=_NextPart_001_01C43384.9C3B5D61 Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN"> <HTML> <HEAD> <META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; = charset=3Dus-ascii"> <META NAME=3D"Generator" CONTENT=3D"MS Exchange Server version = 6.5.6944.0"> <TITLE>Select from (select)</TITLE> </HEAD> <BODY> <!-- Converted from text/rtf format --> <P><FONT SIZE=3D2 FACE=3D"Arial">Is it possible to do a select from a = select statement in Informix?</FONT> </P> <P><FONT SIZE=3D2 FACE=3D"Arial">Ex:</FONT> <BR><FONT SIZE=3D2 FACE=3D"Arial">Select Customer from (Select Customer, = sum(invoiced_amt) as total_spent from Customers group by Customer) where = total_spent &gt; 1000</FONT></P> </BODY> </HTML> ------_=_NextPart_001_01C43...

select of select box will select multiple in another box
Im trying to do the following: I have 2 select boxes, both are pre populated with data. The first box is a single select box, the 2nd is a multiple select box. Depending on the 1st selection, I want to have multiple values in the second select box highlighted. ie box 1 <select name=type> <option> warm colors <option> cool colors <option> shades of grey </select> box 2 <select name=colors multiple> <option> red <option> orange <option> yellow <option> blue <option> green </select> If the user would selec...

Select element with no selected options
Hello All, Is it possible to create a <select> element with no selected options? I have tried setting the selectedIndex attribute to -1, but as far as I can tell this only works for <select multiple> elements. Am I missing something obvious? Sincerely, TJ Walls Ph.D. Candidate - Stony Brook University On Wed, 27 Oct 2004 07:47:47 -0400, TJ Walls <tjwalls@mindspring.nospam.com> wrote: > Is it possible to create a <select> element with no selected options? By not giving any OPTION elements the selected attribute, it is possible for a user agent to initial...

Selected index with multiple select
In a normal select I can see with selectedIndex which option is selected. However, I was wondering how I can see the same thing in a multiple select where more than one option is selected. Kind regards, Wim "Wim Roffal" <wimroffelplease@nospamm-planet.nl> schreef in bericht news:bs1kjm$dv4$1@reader11.wxs.nl... > In a normal select I can see with selectedIndex which option is selected. > > However, I was wondering how I can see the same thing in a multiple select > where more than one option is selected. > This is done by checking if the item's selected...

Select Option & selected
Hello all, I'm currently writing a tiny little bit of navigation to a page, and I've come across this stumbling block: Goto Page&nbsp;&nbsp; <select name="page"> <SCRIPT LANGUAGE="JavaScript1.2" > for ( var inc = 1; inc <= <%=nPages%>; inc++ ){ document.PageForm.page[inc-1] = new Option(inc, inc, ((inc == <%=nPage%>) ? true : false)); } </SCRIPT> </select> On firefox, the select box generated behaves exactly as expected, producing a select with all the 'pages' available, and the currently selected page as...

get the selected OPTION from SELECT
In the code below I want to alert the selected option of select. In Mozilla the code works (If I choose "3" alerts it). In IE alerts: nothing appear --------------------- <script> function hi() { d = document.getElementById("day").value; alert(d); } </script> <select id=day onchange="hi();"> <option>0 <option>1 <option>2 <option>3 <option>4 </select> --------------------- On 11/03/2006 19:31, Chameleon wrote: [Getting selected option element] Read the group FAQ: <http://www.jibbering.com/faq/> ...

file selection dialog
Hi, I'm looking for a file selection dialog to enable a user select multiple files and these files may be in multiple directories. I think most file selection dialogs will do multiple files in one dir, but don't know if all do it over multiple dirs. Many thanks for a link to module/info to implement this in Tk. Thanks. ...

select (select ...)/(select ...) ... -> 0 !!
Hi I need to do a query like this one : Select *, (select count(*) from request where allowed='t' and lead_id=lead.id and lead.affiliate_id=affiliate.id) as nb_bogus_leads, (select count(*) from lead where affiliate_id=affiliate.id) as nb_leads_submitted, (select count(*) from request where allowed='t' and lead_id=lead.id and lead.affiliate_id=affiliate.id)/(select count(*) from lead where affiliate_id=affiliate.id)*100 as percentage_bogus_leads from affiliate where website='dev' but in this one, the part : (select count(*) from request where allowed='t' and lead_id=lead.id and lead.affiliate_id=affiliate.id)/(select count(*) from lead where affiliate_id=affiliate.id)*100 never works and always give me 0 as a result ... Is it possible that postgresql doesn't support expessions like select (select ...)/(select ...) ... ?! Thanks for your help Krystoffff ...

Multiple selection through javascript
Hello I have a multiple select list as follows: <select name="selList" multiple> <option value="1"> Item 1</option> <option value="2"> Item 2</option> <option value="3"> Item 3</option> </select> When the form in which this select list is submitted, I wish to select all items in the list. Therefore on form submit, I call a javascript which does the following: for(i = 0; i < document.forms[0].selList.length; i++) document.forms[0].selList[i].selected = true; Before the submit is done, I can visua...

Select Multiple Options
My tables look basically like: TblCustomer CustomerID Customer TblOption OptionID Option TblCustomerOption CustomerOptionID CustomerID OptionID A customer can select one to seven options. My main form is based on TblCustomer and there is a subform based on TblCustomerOption. The main form and subform are linked on CustomerID. In the subform I would like to show all seven options with a Checkbox beside each option where the option(s) the customer selected can be checked and a record is created in TblCustomerOption for each option checked. Further, I would like to show the options in two colu...

trying to disable a text input field when a particular select list option is selected in a select field but this code has no effect
<script> $(document).ready(function () { $('#select_field').change(function(e) { if (e.target.value=='select_value') {e.second_field.disabled = true;} }) }) </script> On 2015-11-30 05:23, fugee279@gmail.com wrote: > <script> > $(document).ready(function () { > $('#select_field').change(function(e) > { > if (e.target.value=='select_value') {e.second_field.disabled = true;} > }) > }) > </script> Next time, please include the error message you see in the console. The para...

bash select menu select multiple choices
Hello, Using the select method in a menu, I am trying to get multiple choices to work. The results are held in REPLY, but these are just the number choices , how do I access the actual values choosen. Like choices 2 , 5 should be dxjopp and gonp thanks for any pointers. peter. #!/bin/bash PS3="Select name(s)" select choice in `cat users.tmp` do echo "you selected $choice [$REPLY]" echo "choice are :$REPLY" done /menu1 1) pjcon 2) klnon 3) dxjopp 4) eddit 5) gonp Select name(s)3 5 you selected [3 5] choice are :3 5 peter sands wrote: > Hello, > Usin...

HTML Select option selected color style
Is there a style for a select option's "selected" color? For example: <HTML> <BODY> <FORM NAME="form1"> <SELECT NAME="mySelect" SIZE="7" style="background-color:red;"> <OPTION>Test 1 <OPTION>Test 2 <OPTION>Test 3 <OPTION>Test 4 <OPTION>Test 5 <OPTION>Test 6 <OPTION>Test 7 </SELECT> </FORM> </BODY> </HTML> When I select an option it turns blue, I want to override this and make it a different color. In the style I expected something ...

How select a selected option with "value" in IE
Hi, I try to have a communicatition between 2 windows In the first one i have a HTML styled select like that : <form name='addform' id='addform' action='add_dossier.php' method='post' > ...... <select size='1' name='consultant_id' id='consultant_id'> <option value='5'>Paul Poupo</option> <option value='6'>Franck Schmith</option> <option value='17'>Pascal Belci</option> </select> ..... </form> In the second windows (opened by the first) i try to select...

select.select() on windows
I am currently using subprocess to execute a command. Then I read from it's stdout...however, this is hanging on a read..waiting for more bytes. So what I would like is to timeout...and select.selec() seems to be what I need. Except I don't have a socket, i have stdout. Any suggestions on how to do a timeout like select.select with stdout? Thanks you have to use non-block readining. http://docs.python.org/lib/module-select.html: A time-out value of zero specifies a poll and never blocks. jas wrote: > I am currently using subprocess to execute a command. Then I read from &...

assigning 'selected' to option in form select
Hi <form nam="country" ... <select name="industy" ... <option ... selected> ... </option> <option ... Now, in Javascript, I want to change defaulted "selected" to fourth option. document.country.industry.options[3].selected=true; but I get an error. Is the syntax wrong? Regards John -------------------------------------------------------------------------------- I am using the free version of SPAMfighter for private users. It has removed 91027 spam emails to date. Paying users do not have this message in their emails. Try SPAMfi...

Select and Paste Selection
I am trying to select a nearby small patch of skin and paste it to cover a small spot on the face of a child in a photo. First, I note that v 8.10's selection copy and paste as new layer doesn't work quite the same as v 7 did, because you can't just move the pointer to the newly pasted layer and drag it. I seem to have to reselect it and then I can drag and drop it. But once there, even if I merge the layers, that shape shows up in decidedly different colors (black, white, and orange, when what I selected copied and pasted was a little patch of skin. That is, there is something wh...

multiple <select> + IE: selection invisible
hi, I have a php-Script which gets passed a Boat-ID and this is used to mark an element in a <select> as the default: <select name="boote[]" multiple="multiple" size="5"> <option value='43'>Aisha</option> <option value='40'>Amsterdam</option> <option value='55'>Asmaa</option> <option value='20'>Beau Rivage</option> <option value='48'>Blue Perl</option> <option value='49'>Blue Planet 1</option> <option valu...

Multiple Selectable Options in a Menu
HI all, I am required to populate a menu with the column-names of a table, upon right-cliking the header. Now I want that the user can select more than one of the options in the menu. And accordingly I would show only those columns out of the whole collection of columns originally present in the table. This is similar to what we get to see upon right-clicking a table-header in iTunes. Does someone have an idea as to how to go about it? Regards, Ankur <hellbent4u@gmail.com> wrote in message news:1144852866.361636.74770@i40g2000cwc.googlegroups.com... > HI all, > > I am req...

RE: Select from (select)
try this: select customer, sum(invoiced_amt) as total_spent from customers group by customer having sum(invoiced_amt) > 1000 Andy ________________________________ From: owner-informix-list@iiug.org [mailto:owner-informix-list@iiug.org] On Behalf Of Phillips, Rob Sent: Thursday, May 06, 2004 11:10 AM To: informix-list@iiug.org Subject: Select from (select) Is it possible to do a select from a select statement in Informix? Ex: Select Customer from (Select Customer, sum(invoiced_amt) as total_spent from Customers group by Customer) where total_spent > 1000 sending to informix-list Hi, An option more: create view view1 (col1, col2) as select customer, sum(invoiced_amt) from customers group by customer ; select * from view1 where col2 > 1000 After that: Remember that "view1" exists in your database until you "drop view" it ... BR R.Ferronato "Bent_Andy" <abent@aetinc.com> wrote in message news:<c7dpnr$a80$1@terabinaries.xmission.com>... > try this: > > select customer, sum(invoiced_amt) as total_spent > from customers > group by customer > having sum(invoiced_amt) > 1000 > > Andy > > ________________________________ > > From: owner-informix-list@iiug.org > [mailto:owner-informix-list@iiug.org] On Behalf Of Phillips, Rob > Sent: Thursday, May 06, 2004 11:10 AM > To: informix-lis...

vector selection of a selection
suppose i have a= [1 2 3 4 5 6 7 8 9] somewhere in my code i have for example: a(5:8) is it possible to select the last two elements of a(5:8) in a single statement so something like a(5:8)(end-1:end)?? On 2006-05-18 20:03 kanivan said the following: > suppose i have a=3D [1 2 3 4 5 6 7 8 9] >=20 > somewhere in my code i have for example: > a(5:8) >=20 > is it possible to select the last two elements of a(5:8) in a single > statement so something like a(5:8)(end-1:end)?? No not in general, but you could use an anonymous function (but I don=B4t= =20 really see the point...

modify the default option in a select changing another select
I wish to know if is possible to change the selected option in a SELECT selecting a determined option into another SELECT in the same form. E.g: When I select the option "Istruction" in the SELECT named "A" I wish the SELECT "B" change the default state from "empty" to "other" Thank You Here is a litle example of... <html> <body onload="changeEvent()"> <script language="JavaScript"> <!-- function changeEvent() { if (document.forms[0].items.selectedIndex == 0) document.forms[0].subItems....

select ... Minus select ...
Wie lautet der Befehl um eine Selectabfrage ohne die Zeilen der zweiten zubekommen? Der Befehle UNION vebindet zwei Abragen und liefert die Zeilen beider Abfragen. In SQL-B�chern gibt es den Befehl MINUS: Select * from tabelle1 MINUS Select * frim tabelle2 ... Das versteht Foxpro aber nicht. Heisst der Befehle in Foxpro anders oder gibt es da gar nicht. Wenn nein, welch Alternativen gibt es? In article <c49bc3f0.0309250130.49bc3bbf@posting.google.com>, Daniel wrote: > Wie lautet der Befehl um eine Selectabfrage ohne die Zeilen der zweiten zubekommen? > > Der Be...

Web resources about - options.selected on select multiple - comp.lang.javascript

Portal:Bollywood/Selected biography - Wikipedia, the free encyclopedia
Write three or four paragraphs in the text field using information from the selected notable article, you may find it useful to examine the existing ...

F8: Facebook’s FbStart Initiative Will Give Selected Developers A $30K Kick-Start
... successful applications is likely a whole lot easier with $30,000 in free tools and services to start off with, and that’s exactly what selected ...

LEGO Shop - The LEGO Technic team has selected the winner... - Facebook
The LEGO Technic team has selected the winner of the Co-Creation Challenge! LEGO will be producing a limited run of 20,000 of this stunning set.... ...

Grand Doctor Ma Selected Students-baby365 on the App Store on iTunes
Get Grand Doctor Ma Selected Students-baby365 on the App Store. See screenshots and ratings, and read customer reviews.

Selected Cheney Vice Presidential Photographs
... for photos found within these albums are Paul Morse, Karen Ballard, Kimberlee Hewitt, Shealah Craighead, and Chris Greenberg. These selected ...

[iOS Advice] How To Clarify Your Email Replies By Quoting Selected Text - YouTube
Follow me on Twitter: http://www.twitter.com/macmixing Like my Facebook page: http://www.facebook.com/macmixing RATE, COMMENT, SUBSCRIBE! :-) ...

UAE Under-19 cricketers for ACC Premier League tour of Malaysia selected - The National
Coach Aaqib Javed seeking fresh blood for senior team after missing out on World Twenty20

Animal of the Day: Lucius Has Been Selected as the U.K.’s ‘Happiest Cat’
He’s got one blue eye, one green eye and a heart of gold. British mobile phone company O2 recently held some “cat auditions” to find “the UK’s ...

Australian director Sue Brooks 'gobsmacked' as Looking for Grace selected for Venice Film Festival competition ...
... filmmaker Sue Brooks says she is "gobsmacked". Her drama Looking For Grace , shot in the Western Australian wheat belt, has been selected for ...

Three Canberra products selected in AFL state combines
Belconnen junior Chris Jansen has been selected in South Australia's state AFL combine.

Resources last updated: 3/12/2016 6:22:58 AM