473,320 Members | 1,922 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

trying to insert select options with JS at run time.

How come this works

http://www.geocities.com/tekmonk2005...electJS00.html

works fine in Konqueror, but this

http://www.geocities.com/tekmonk2005...electJS02.html

doesn't in FireFox, Internet Explorer and Opera (which apparently
tries to render two select boxes)?

The only difference is that in the second case the <select ...>
statement is included in the HTML code, in order to explicitily declare
the style right in the <select ...> statement (which is what I would
like to do), where as in the first case the "select" part is also
string'ed together as part of the options.

I would like to pass to the .innerHTML property the actual option
values of a form's select box.

How can you do that in a consistent/crossbrowser way?

otf

Apr 9 '06 #1
2 4941
onetitfemme wrote:
How come this works

http://www.geocities.com/tekmonk2005...electJS00.html

works fine in Konqueror, but this

http://www.geocities.com/tekmonk2005...electJS02.html

doesn't in FireFox, Internet Explorer and Opera (which apparently
tries to render two select boxes)?

The only difference is that in the second case the <select ...>
statement is included in the HTML code, in order to explicitily declare
the style right in the <select ...> statement (which is what I would
like to do), where as in the first case the "select" part is also
string'ed together as part of the options.

I would like to pass to the .innerHTML property the actual option
values of a form's select box.

How can you do that in a consistent/crossbrowser way?

Use DOM methods rather than innerHTML.

Also you should use type="text/javascript" rather than language="JavaScript.

--
Ian Collins.
Apr 9 '06 #2
onetitfemme said on 10/04/2006 6:20 AM AEST:
How come this works

http://www.geocities.com/tekmonk2005...electJS00.html

works fine in Konqueror, but this

http://www.geocities.com/tekmonk2005...electJS02.html

doesn't in FireFox, Internet Explorer and Opera (which apparently
tries to render two select boxes)?

The only difference is that in the second case the <select ...>
statement is included in the HTML code, in order to explicitily declare
the style right in the <select ...> statement (which is what I would
like to do), where as in the first case the "select" part is also
string'ed together as part of the options.

I would like to pass to the .innerHTML property the actual option
values of a form's select box.

How can you do that in a consistent/crossbrowser way?


The most cross-browser way to add options is to use new Option:

selRef(selRef.options.length) =
new Option([text, [value, [defaultSelected, [selected]]]])
Where all parameters are optional and:

text is the option text
value is the default value
selected is a boolean (true/false) to make the option selected
defaultSelected is a boolean to make the option the default selected

new Option() is DOM 0 and widely implemented, support is likely never to
be dropped.

--
Rob
Group FAQ: <URL:http://www.jibbering.com/FAQ>
Apr 9 '06 #3

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

Similar topics

3
by: jason | last post by:
How does one loop through the contents of a form complicated by dynamic construction of checkboxes which are assigned a 'model' and 'listingID' to the NAME field on the fly in this syntax:...
1
by: SAN CAZIANO | last post by:
how can clear an html SELECT and next insert in it all the elements of an array () I try this but seems doesn't works. function ComboAddArrayValueWithLabel(combo,ArrayLabel,ArrayValue) { ...
13
by: kevinold | last post by:
Hello everyone, I have a list of about 1600 employees that I'd like to have displayed in a form. I'd like to make the "search" for the user as easy as possible. I ran across this:...
4
by: radhika | last post by:
Problem: Huge Inserts with select clause like Insert into table TABLE1 select ......from x union select ....from y; I get Transaction Log Full Error so did this
2
by: ven | last post by:
Hello i have two tables in my MS SQL named table1 and table2. In each table i have a column PRICE with my own datatype decimal 14;4 allows nulls.... now i wanna select from one table to second...
5
by: Learner | last post by:
Hello, Here is the code snippet I got strucked at. I am unable to convert the below line of code to its equavalent vb.net code. could some one please help me with this? static public...
3
by: Dodger | last post by:
I've been working on this little doohickey for a bit now... (please ignore the speed issues of some of the queries -- things aren't all optimised up in mysql yet) ...
11
by: Chuck | last post by:
Can the SQL code from an Append query be inserted into the form module? The form module currently has a DoCmd Run Macro statement. The Macro opens the Append query which runs correctly. I'm trying...
1
by: mcf747 | last post by:
Hello, I am trying to make a digital time card but with some advanced reporting and options that I will integrate. I have been stuck on something for about 3 months now on and off and I have...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.