Hi wats wrng with this code??? it works fine on IE6 but not on FireFox
1.5???
var anOption = document.create Element("OPTION ");
document.getEle mentById("categ ory").options.a dd(anOption);
anOption.innerT ext = "NewElement ";
anOption.Value = "99"; 4 62200 mi******@gmail. com wrote: Hi wats wrng with this code??? it works fine on IE6 but not on FireFox 1.5???
var anOption = document.create Element("OPTION "); document.getEle mentById("categ ory").options.a dd(anOption);
The W3C DOM Level 2 HTML defines an add method for the select element object
<http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-94282980>
but not for the options collection. However using that method is
difficult as IE implements the method with the same name with different
parameters.
If you simply want to add an option then using the DOM Level 0
var select = document.forms. formName.elemen ts.selectName;
select.options[select.options. length] = new Option('text', 'value');
is much better in terms of browser compatibility.
anOption.innerT ext = "NewElement ";
Firefox does not support the innerText property at all. For option
element objects you can set
anOption.text
anOption.Value = "99";
JavaScript is case sensitive, the property is named value and not Value.
--
Martin Honnen http://JavaScript.FAQTs.com/
---------------------
var select = document.forms. formName.elemen ts.selectName;
select.options[select.options. length] = new Option('text', 'value');
---------------------
wow, it worked..
after posting i realised the Cap-Letter 'V' => value.. neways my last
question.. how do i deal with this????
anOption.select ed = true;
thnx a lot!!!
Martin Honnen wrote: mi******@gmail. com wrote:
Hi wats wrng with this code??? it works fine on IE6 but not on FireFox 1.5???
var anOption = document.create Element("OPTION "); document.getEle mentById("categ ory").options.a dd(anOption);
The W3C DOM Level 2 HTML defines an add method for the select element object <http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-94282980> but not for the options collection. However using that method is difficult as IE implements the method with the same name with different parameters. If you simply want to add an option then using the DOM Level 0 var select = document.forms. formName.elemen ts.selectName; select.options[select.options. length] = new Option('text', 'value'); is much better in terms of browser compatibility.
anOption.innerT ext = "NewElement ";
Firefox does not support the innerText property at all. For option element objects you can set anOption.text
anOption.Value = "99";
JavaScript is case sensitive, the property is named value and not Value.
--
Martin Honnen http://JavaScript.FAQTs.com/
new Option('text', 'value', 'TRUE');
solved it!!!!!
thnx mi******@gmail. com wrote: --------------------- var select = document.forms. formName.elemen ts.selectName; select.options[select.options. length] = new Option('text', 'value'); ---------------------
wow, it worked..
after posting i realised the Cap-Letter 'V' => value.. neways my last question.. how do i deal with this????
anOption.select ed = true;
thnx a lot!!!
Martin Honnen wrote: mi******@gmail. com wrote:
Hi wats wrng with this code??? it works fine on IE6 but not on FireFox 1.5???
var anOption = document.create Element("OPTION "); document.getEle mentById("categ ory").options.a dd(anOption);
The W3C DOM Level 2 HTML defines an add method for the select element object <http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-94282980> but not for the options collection. However using that method is difficult as IE implements the method with the same name with different parameters. If you simply want to add an option then using the DOM Level 0 var select = document.forms. formName.elemen ts.selectName; select.options[select.options. length] = new Option('text', 'value'); is much better in terms of browser compatibility.
anOption.innerT ext = "NewElement ";
Firefox does not support the innerText property at all. For option element objects you can set anOption.text
anOption.Value = "99";
JavaScript is case sensitive, the property is named value and not Value.
--
Martin Honnen http://JavaScript.FAQTs.com/ mi******@gmail. com wrote: new Option('text', 'value', 'TRUE');
solved it!!!!!
Pass in a boolean there e.g.
new Option('text', 'value', true, true)
where the third argument is for the default selected and the fourth for
the selected value (both which are boolean values).
--
Martin Honnen http://JavaScript.FAQTs.com/ This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Dave |
last post by:
I have a page which uses JavaScript to create form elements using
document.createElement('input'), etc.. Both Firefox and IE have no
problem accomplishing this and when the form is submitted all the
information is passed correctly.
I am now trying to validate the form using JavaScript when the page is
submitted. Firefox has no problems with...
|
by: rain_c1 |
last post by:
Hi!
I have problems with document.createElement() in IE when using TR tags.
Please look at the following very short example:
------------snip-----------------
<table id="test"></table>
<script type="text/javascript">
var MyTable = document.getElementById("test");
|
by: gabon |
last post by:
I'm creating a select entirely through JavaScript and very strangely IE
doesn't show the text in the option elements.
Here part of the code:
this.form_country=document.createElement("select");
var option;
for(var i=0; i<arr.length; i++){
option=document.createElement("option");
option.value=arr.code;
|
by: raoul |
last post by:
MSIE 6.0 apparently does not support protyping with objects created
with document.createElement, while Firefox does.
I tested it by typing it into the adress bar, but it also appears to be
the case for code embedded in a HTML document. Here's a simple segment
of code to demonstrate the difference:
javascript: function...
|
by: webEater |
last post by:
Hello, I try the following in Firefox and other modern browsers:
window.addEventListener('load', function() {
document.title = CSS.getClass('fontSize');
var div = document.createElement('div');
document.getElementsByTagName('body').appendChild(div);
alert(div);
alert(div.style)
}, true);
| |
by: ssh |
last post by:
function testfn(name)
var tbody = document.getElementById('hellospace').getElementsByTagName('tbody');
var row = document.createElement('TR');
var cell1 = document.createElement('TD');
cell1.align="left";
cell1.style.height = "22";
cell1.style.width = "15";
cell1.valign = "middle";
cell1.className = "dwInfo";
var inp1 =...
|
by: r_ahimsa_m |
last post by:
Hello,
I am learning JavaScript. I have a table on HTML page:
        <table id="announcement_fields" border="0">
        <tbody>
        <tr>
        <td><span class="obligatory">Offer type</span>:</td>
        <td>
            <select...
|
by: vunet |
last post by:
It is recommended by some sources I found to create IFrames in IE
using
document.createElement('<iframe src="#">')
instead of document.createElement('iframe').
Why and what browser versions to use it? IE5 or IE6?
Thanks
|
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...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language...
|
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. ...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
|
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...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...
| |