473,474 Members | 1,822 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Preserving input values in innerHTML with Mozilla

I'm moving big chunks of html into and out of divs using innerHTML.
Or, I thought I was until I tested it on Firefox 1.5. Firefox will
move the html just fine, but if you have changed any input values in
that html (checkbox, radio, or text values), those new values won't
come along with the html --only their initial values when the html was
made. Internet Explorer 6 does bring the new values along with the
html. If I have to I can parse through the DOM and move all those
values over one-by-one, but I'm hoping there's a simpler solution
available. (I realize Microsoft made innerHTML and that it's still
proprietary --maybe that accounts for the "partial" implementation by
Mozilla.)

Thanks for your help,
Dennis

Jan 24 '07 #1
2 2690


On Jan 25, 7:24 am, mypublicm...@adelphia.net wrote:
I'm moving big chunks of html into and out of divs using innerHTML.
Or, I thought I was until I tested it on Firefox 1.5. Firefox will
move the html just fine, but if you have changed any input values in
that html (checkbox, radio, or text values), those new values won't
come along with the html --only their initial values when the html was
made. Internet Explorer 6 does bring the new values along with the
html. If I have to I can parse through the DOM and move all those
values over one-by-one, but I'm hoping there's a simpler solution
available. (I realize Microsoft made innerHTML and that it's still
proprietary --maybe that accounts for the "partial" implementation by
Mozilla.)
I think you've answered your own question. Input and similar elements
have DOM attributes for value and default value, however only one can
be represented in HTML. The decision of which value to include seems
to be reflected in the innerHTML property and as you point out, the
lack of a standard means there's no consistency in that regard
(although having a standard may not help anyway :-) ).

I guess you could write your own serialiser for converting such
elements from HTML to say JSON - add your own custom attribute for
default value to preserve the DOM defaultValue attribute and use the
current value as the value attribute.

Even if you do that, when you write it back to the page, how to you
deal with the value and default value thing?
--
Rob

Jan 25 '07 #2


On Jan 24, 11:18 pm, "RobG" <r...@iinet.net.auwrote:
On Jan 25, 7:24 am, mypublicm...@adelphia.net wrote:
I'm moving big chunks of html into and out of divs using innerHTML.
Or, I thought I was until I tested it on Firefox 1.5. Firefox will
move the html just fine, but if you have changed any input values in
that html (checkbox, radio, or text values), those new values won't
come along with the html --only their initial values when the html was
made. Internet Explorer 6 does bring the new values along with the
html. If I have to I can parse through the DOM and move all those
values over one-by-one, but I'm hoping there's a simpler solution
available. (I realize Microsoft made innerHTML and that it's still
proprietary --maybe that accounts for the "partial" implementation by
Mozilla.)I think you've answered your own question. Input and similar elements
have DOM attributes for value and default value, however only one can
be represented in HTML. The decision of which value to include seems
to be reflected in the innerHTML property and as you point out, the
lack of a standard means there's no consistency in that regard
(although having a standard may not help anyway :-) ).

I guess you could write your own serialiser for converting such
elements from HTML to say JSON - add your own custom attribute for
default value to preserve the DOM defaultValue attribute and use the
current value as the value attribute.

Even if you do that, when you write it back to the page, how to you
deal with the value and default value thing?
Thanks -- making a custom attribute (eg, 'newval') for each input
object is how I'll do it. When a user clicks on, say, a checkbox, I'll
call a JS function to set the attribute 'newval' to either 'checked' or
'unchecked'. Right after I innerHTML that code to its new home, I'll
loop through all the input objects and for any that have a
newval=checked or newval=unchecked, I'll use JS to manually check or
uncheck them. But it would have been cleaner if innerHTML would do
that for me automaticallly (as it does in IE6).

Jan 25 '07 #3

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

Similar topics

8
by: Kyle | last post by:
I am presently making use of documentElement.innerHTML to retrieve page contents for manipulation, but I've noticed that the sting value returned is not identical to the actual page source....
11
by: kaeli | last post by:
Hey all, AFAIR, innerHTML started as MS proprietary, but Mozilla implemented it as well. Does anyone know if any other browsers support it? It is not in the W3C DOM, is it? A quick GIS seemed to...
16
by: TTroy | last post by:
Hello, I'm relatively new to C and have gone through more than 4 books on it. None mentioned anything about integral promotion, arithmetic conversion, value preserving and unsigned preserving. ...
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: SimonV | last post by:
Hmm, I let the user add more input fields as needed. But I have a strange problem with ff (and other mozillas) When I add a field in ff, the others lost their content... In IE the content stays...
8
by: Clément | last post by:
Hi! I am currently developping a user interface with Ajax/C#/.net. And I am facing a problem with Mozilla, and Firefox. I use the function innerHTML to load a Web UserControl into a div, this...
7
by: Nez | last post by:
Help needed! Hello, I have looked everywhere for a solution to my problem and this is pretty much my last resource. I have created a table in a span with the innerhtml command in my code behind....
6
by: CES | last post by:
All, Visual Studio 2005 doesn't include an auto complete item for innerHTML document.getElementById("SomeID").innerHTML, is their a way of referencing the inner text of an element without using...
3
by: sophia.agnes | last post by:
Dear all, I was going through the book "C a software engineering approach by darnell & Margolis" there was a section named sign preserving vs value preserving it is as follows sign...
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,...
0
jinu1996
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...
1
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...
0
tracyyun
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...
0
agi2029
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,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
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 ...
0
bsmnconsultancy
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...

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.