Why doesn't a SELECT element's innerHTML reflected which option was
selected? Works in IE. I need this functionality so that I can retain
what choices a user made in a tabbed interface.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">
<html xmlns="http://w3.org/1999/xhtml">
<head>
<script language="javas cript">
function callAlert(){
var theHTML = document.getEle mentById('Radiu s').innerHTML;
//alert(theHTML);
}
</script>
<title>Untitl ed Document</title>
</head>
<body>
<form id="myForm">
<div id="myDiv">
<table border="0" width="430" cellpadding="3" cellspacing="0" >
<tr>
<td font color="#ff0000" >*</font>Radius:</td>
<td width="331" height="30" class="formData ">
<select onChange="callA lert();" id="Radius" name="Radius">
<option value=".10" id="0">1/10 mile</option>
<option value=".20">1/5 mile</option>
<option value=".25">1/4 mile</option>
<option value=".5">1/2 mile</option>
<option value=".75">3/4 mile</option>
<option value="1">1 mile</option>
</select>
</td>
</tr>
</table>
</div>
</form>
</body>
</html> 24 3507
On 10/07/2005 23:20, bedhead wrote: Why doesn't a SELECT element's innerHTML reflected which option was selected?
The selected attribute refers to pre-selection, not whether the element
is currently selected. Markup is static and doesn't change in response
to user actions.
I need this functionality so that I can retain what choices a user made in a tabbed interface.
Read the values from object properties and reassign them later.
[snip]
Mike
--
Michael Winter
Prefix subject with [News] before replying by e-mail.
bedhead wrote: Why doesn't a SELECT element's innerHTML reflected which option was selected? Works in IE. I need this functionality so that I can retain what choices a user made in a tabbed interface.
What are you looking for? The option's value, the option's text or the
option's selected index?
[...] <script language="javas cript"> function callAlert(){ var theHTML = document.getEle mentById('Radiu s').innerHTML; //alert(theHTML); } </script>
Why not pass the select object to the callAlert function?
<script type="text/javascript">
function callAlert(menu) {
alert(menu.opti ons[menu.selectedIn dex].value);
alert(menu.opti ons[menu.selectedIn dex].text);
alert(menu.sele ctedIndex);
}
</script>
<select onChange="callA lert(this);" id="Radius" name="Radius">
Help?
[...]
Mick
bedhead <ms***@consults haw.com> wrote in message news:11******** **************@ g43g2000cwa.goo glegroups.com.. . Why doesn't a SELECT element's innerHTML reflected which option was selected? Works in IE. I need this functionality so that I can retain what choices a user made in a tabbed interface. http://jibbering.com/FAQ/#FAQ4_13
Using the above technique, assign your form a NAME not an ID. Reading form elements does not involve
document.getEle mentById or .innerHTML. Please tell all your friends and ask them to tell all their friends etc.
--
Stephen Chalmers
"Stephen Chalmers" <ig******@lycos .co.uk> writes: http://jibbering.com/FAQ/#FAQ4_13
Using the above technique, assign your form a NAME not an ID.
I assume you refer to "id" and "name" attributes, but capitalizing
risks confuzing with HTML data types ID and NAME
<URL:http://www.w3.org/TR/html4/types.html>.
Anyway, give it an "id" attribute, not a name attribute, if you are
writing HTML 4 or later. The "name" attribute is not valid on form
elements at all. The only reason for using the "name" attribute is to
be compatible with Netscape 4 or its contemporaries, and in that case,
you should still use the valid "id" attribute with the same name.
The W3C DOM 2 HTML says that the forms collection (an
HTMLNodeCollect ion) can be indexed using the elements names or id's,
so using an "id" attribute still works.
/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleD OM.html>
'Faith without judgement merely degrades the spirit divine.'
Lasse Reichstein Nielsen wrote: The "name" attribute is not valid on form elements at all. The only reason for using the "name" attribute is to be compatible with Netscape 4 or its contemporaries, and in that case, you should still use the valid "id" attribute with the same name.
1) name attributes on form tags certainly is valid html 4.01.
2) Multiple forms can have the same name, but multiple forms may not have
the same id. In some cases, this might be an important fact.
--
Matt Kruse http://www.JavascriptToolbox.com http://www.AjaxToolbox.com
On 11/07/2005 01:06, Matt Kruse wrote: Lasse Reichstein Nielsen wrote:
The "name" attribute is not valid on form elements at all. The only reason for using the "name" attribute is to be compatible with Netscape 4 or its contemporaries, and in that case, you should still use the valid "id" attribute with the same name. 1) name attributes on form tags certainly is valid html 4.01.
Correct. They're also valid in XHTML 1.0 Transitional (but not Strict).
2) Multiple forms can have the same name [...]
No. The name and id attributes share the same namespace for most
elements. The uniqueness constraint applies equally when using either
attribute with a FORM element, as well as A, APPLET, FRAME, IFRAME, IMG
and MAP elements. See a few paragraphs into section 12.2.3 - Anchors
with the id attribute.
Mike
--
Michael Winter
Prefix subject with [News] before replying by e-mail.
Thanks for all the replies. Sorry for the confusion. This is just a
small example. I am getting the innerHTML of a DIV tag which
encompasses a very large form. I didn't want to get all the selected
indexes, checked, etc... of all elements in the form and restore them
later.
IE actually changes the innerHTML of the DIV to reflect what the user
selected. So, if you save the innerHTML you have their choices. I
would like to do a similar thing in FireFox if available.
Does innerHTML have similar functionality in FireFox? If not, is
saving all the current choices the only way to accomplish this?
Thanks
"Matt Kruse" <ne********@mat tkruse.com> writes: 1) name attributes on form tags certainly is valid html 4.01.
So it is! It was just HTML 4.0 where it wasn't. It's not incorrect that
it's for compatability with old browsers though, as they say:
---
name = cdata [CI]
This attribute names the element so that it may be referred to from
style sheets or scripts. Note. This attribute has been included for
backwards compatibility. Applications should use the id attribute to
identify elements.
---
For style sheets, they have to mean using the [name="something "]
selector which IE still doesn't support (like most CSS2).
2) Multiple forms can have the same name, but multiple forms may not have the same id. In some cases, this might be an important fact.
And whenever a form has both an id and a name, it must be the same :)
I fail to see an application where multiple forms with the same
element is the best way to do anything, but it is allowed.
/L 'just use "id"!'
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleD OM.html>
'Faith without judgement merely degrades the spirit divine.'
bedhead wrote: Thanks for all the replies. Sorry for the confusion. This is just a small example. I am getting the innerHTML of a DIV tag which encompasses a very large form. I didn't want to get all the selected indexes, checked, etc... of all elements in the form and restore them later.
IE actually changes the innerHTML of the DIV to reflect what the user selected. So, if you save the innerHTML you have their choices. I would like to do a similar thing in FireFox if available.
Does innerHTML have similar functionality in FireFox?
No. Given that 'innerHTML' is not a public standard nor fully
documented anywhere, whatever behaviour it has is what it has. As it is
a Microsoft invention, you could argue that any browser that doesn't do
what IE does has a faulty implementation.
But IE's version has its own problems: if you serialise the select
element with the user's currently selected options as 'selected', you
will need to code your own reset button as the original defaults are gone.
If you restore the page with the previously selected options being set
as 'selected' in the HTML, you will have the same problem however you
implement it - you will have to provide your own reset button.
If not, is saving all the current choices the only way to accomplish this?
Why not use display: none for non-selected tabs? The content stays in
the page and there are no issues with restoring forms. If you do the
layout right, with JavaScript disabled the tabs should just appear one
above the other and have anchors to navigate between them. With JS
enabled, they behave like tabs - hiding and showing the relevant bits.
--
Rob This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: catorcio |
last post by:
I'm trying to have some text in my page changed by clicking
a button. Googleing around I've discovered that innerText
doesn't work with every browser, so I've switched to
innerHTML. It works fine on IE and Opera, but nothing
happens on Firefox (just updated to version 1.0.4).
Any suggestions?
Thanks in advance! C.
|
by: Astra |
last post by:
Hi everybody
Wonder if you could help me out.
I created a simple JavaScript routine to enable a user to click backwards
and forwards between small news articles. This routine works fine in IE and
Safari, but in the latest FireFox I get no title or article, but do see the
prev and next links and the article number.
My HTML and JS simple routine is as follows:
|
by: Craig Keightley |
last post by:
Please help, i have attached my page which worksin IE but i cannnot get the
drop down menu to fucntion in firefox. Any one have any ideas why?
Many Thanks
Craig
<<<<<<<<<<<<<<CODE>>>>>>>>>>>>>>>>
<html>
|
by: Jake Barnes |
last post by:
I wanted to teach myself AJAX this weekend so I sat down with Stuart
Landgridge's book and I started to play around. I came up with a little
page that you can add text and images to. You can see it here:
http://www.publicdomainsoftware.org/ajaxExperiment.htm
Click in any box to get the controls with which you can play around.
This function below, askForInput, was working the way I wanted, till I
tried to give it two parameters, one...
|
by: Jake Barnes |
last post by:
This weekend I wanted to learn AJAX, so I set up a little toy page
where I could experiment. The idea of this page is that you click in
one of the boxes to get some controls, at which point you can add text,
images, or HTML to the box. This seems to work fine in FireFox, but not
in IE. You can see the problem here:
http://www.publicdomainsoftware.org/ajaxExperiment.htm
In FireFox, if you click in a box and then select "Add HTML" you...
| |
by: sveinn |
last post by:
Hi all,
I've read through this group searching for an answear about this
problem.
Few have come close but not quite what I need.
My problem is this: I'm using Ajax to fetch a new table with input
boxes. I then take
the innerHTML from my <div> and add the new table to the existing
one/s.
What happens in FireFox is that all values in other tables input boxes
|
by: Hoss |
last post by:
Hello all-
This is what im trying to achieve. At the top of my page there is some
search functionality, through which you cause to be loaded a string
representing an HTML page. Below this and occuupying about 80% of the
window real estate, there is a DIV. There is also a toggle button with
two options "Code View" and "Text View" as I have named them. Depending
on which mode you are in, you can see the block of HTML either as code
(in...
|
by: uwe.braunholz |
last post by:
Hello,
I want to set the text of a marqee dynamical. So I created the
following code:
****snip****
<style>
#noticeMarquee
{
background-color:#ff00ff;
color:#ffffff;
|
by: tcole6 |
last post by:
My problem appears to be Firefox specific.
I have a hyperlink that loads a new window. This window contains
hyperlinks that call javascript functions in the parent window and then
closes the child window. The function that is called contains an
XMLHttpRequest.
My problem is that everything happens as it should, the innerHTML is
changed by the results of the XMLHttpRequest and the child window
closes. The problem is this, in Firefox,...
|
by: raju78.k |
last post by:
Hi,
I have a problem with FireFox. I have written a function to Add rows
without submiting the form. This function works fine in IE, but not in
FireFox.
The function is :
function
createRows(deviceId,deviceType,modelName,ipAddress,macAddress,imageURL)
|
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 usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
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.
| |