473,385 Members | 1,720 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,385 software developers and data experts.

questions about SELECT and innerHTML

I tried to do this to change the OPTION part of a SELECT.

cust.innerHTML = "<option value='AAA'>AAA</option><option
value='BBB'>BBB</option><option value='CCC'>CCC</option><option
value='DDD'>DDD</option><option value='EEE'>EEE</option>";

It won't work at all. After tracing a while, I found it became like ...

AAA</option><option value='BBB'>BBB</option><option
value='CCC'>CCC</option><option value='DDD'>DDD</option><option
value='EEE'>EEE</option>

in the OPTION part of that SELECT. Is there anything wrong? Or it's the way
it should be. And is there any work aorund?

Jack
Jul 23 '05 #1
1 3312


datactrl wrote:
I tried to do this to change the OPTION part of a SELECT.

cust.innerHTML = "<option value='AAA'>AAA</option><option
value='BBB'>BBB</option><option value='CCC'>CCC</option><option
value='DDD'>DDD</option><option value='EEE'>EEE</option>";


There have always been other APIs to add/remove options from a <select>
element for instance since Netscape 3
selectElement.options[selectElement.options.length] =
new Option('text', 'value')
to add an option and
selectElement.options[someIndex] = null
to remove an option.
You can also since IE5 and Netscape 6 or with other DOM compliant
browsers use the DOM to create and insert or to remove options.
--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 23 '05 #2

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

Similar topics

5
by: cedawe | last post by:
I have two select boxes. When the user picks a value in the first one it completely re-populates the second one. It works fine, but only generates a standard OPTIONS list and I now want to group...
4
by: Michael Schuerig | last post by:
I'm trying to change the options of a select element by setting its innerHTML. Here's a demo case: <html> <head> <script language="javascript" type="text/javascript"> function addOpts() { var...
10
by: Russ | last post by:
I've been trying to figure out how to show a simple messagebox with an OK button in my web client program (C#). I have looked at every reference to JScript and MessageBox that seemed even remotely...
38
by: Luke Matuszewski | last post by:
Welcome I have read the in the faq from jibbering about the generic DynWrite, but i also realized that is uses only innerHTML feature of HTML objects. (1) Is there a DOM function which is very...
4
by: Ian Richardson | last post by:
Hi, The function I've put together below is a rough idea to extend a SELECT list, starting from: <body> <form name="bambam"> <select id="fred"> <option value="1">1</option> <option...
1
by: Jan Doggen | last post by:
Hello all, I have a SELECT like this (the 'alert()s are temporary): <FORM method="POST" action="/scripts/runisa.dll?OVB2.132964:PGSPLITVACAFMELDEN:1095144287.9159" id="hulpform"...
10
by: mjpdatadev | last post by:
I am relatively new to XMLRequest, DOM and Ajax but I really like the functionality. I have the DIV and SPAN changes working well but I thought that I would experiment with changing the actual...
3
by: Italio Novuas | last post by:
Hi all, let me begin by saying that I *ALMOST* have this complete! What I'm trying to do is make it so my text area shows the innerHTML of any select item with the same value. For example, if I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...

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.