473,320 Members | 1,832 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.

onchange seems not to work with DOM

Hi there,

I've written some kind of menu to display a diagram with input fields
for a budget plan.
A user should be able to change values, which are initially filled by
a database value, and get all corresponding values filled by the
program.

//value given by database
showText[k].setAttribute("value", eval("liste[i][TEXT" + k + "]"));

//onchange event for the user to change the value
showText[k].setAttribute("onchange", "calculate('cost" + i + "')");

//function to recalculate corresponding values
function calculate(myId) {
if (myId == "initial") {
...
}
else {
myId = myId.slice(4);
//getParents(myId) returns corresponding values for myId
var myParents = getParents(myId);
for (var i = deep; i >= 0; i--) {
var sum = 0;
for (var j = 0; j < myParents.length; j++) {
...
for (var k = 0; k < children.length; k++) {
sum +=
parseFloat(document.getElementById(eval("'cost" + children[k] +
"'")).getAttribute("value"));
}
}
}
}
}
}

My Problem is:
IE and Netscape always use the value initially entered by the database
and not the new value entered by the user.
Is there a timing or DOM problem?

Thanks for help...
Jul 20 '05 #1
5 3755


Christian wrote:
A user should be able to change values, which are initially filled by
a database value, and get all corresponding values filled by the
program.

//value given by database
showText[k].setAttribute("value", eval("liste[i][TEXT" + k + "]"));
I guess
showText[k].value = liste[i]['TEXT' + k];
is all you need.
//onchange event for the user to change the value
showText[k].setAttribute("onchange", "calculate('cost" + i + "')");


showText[k].onchange = new Function ("evt",
"calculate('cost" + i + "');"
);

--

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

Jul 20 '05 #2
@ Martin Honnen <ma*******@yahoo.de>

Thanks a lot! Now it works.

But why doesn't IE understand "setAttribute()"?
Shouldn't this be a standard for DOM?

Thanks, Christian
Jul 20 '05 #3
On 9 Feb 2004 23:34:30 -0800, Christian <ch***************@gmx.de> wrote:
@ Martin Honnen <ma*******@yahoo.de>

Thanks a lot! Now it works.

But why doesn't IE understand "setAttribute()"?
Shouldn't this be a standard for DOM?


It is part of the DOM Core Specification (all versions). However,
Microsoft seem to have terrible problems implementing standards that
aren't their own, even if they are several years old.

Mike

--
Michael Winter
M.******@blueyonder.co.invalid (replace ".invalid" with ".uk" to reply)
Jul 20 '05 #4


Christian wrote:

But why doesn't IE understand "setAttribute()"?
Shouldn't this be a standard for DOM?


IE's object model has grown from IE4 before there was any W3C DOM
specification. It supports a setAttribute method but it works different
from what the DOM specification suggests.

--

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

Jul 20 '05 #5
On Tue, 10 Feb 2004 12:02:56 GMT, Michael Winter
<M.******@blueyonder.co.invalid> wrote:
On 9 Feb 2004 23:34:30 -0800, Christian <ch***************@gmx.de> wrote:


[snip]
But why doesn't IE understand "setAttribute()"?
Shouldn't this be a standard for DOM?


It is part of the DOM Core Specification (all versions). However,
Microsoft seem to have terrible problems implementing standards that
aren't their own, even if they are several years old.


Ignore that. It was an unfair and biased generalisation against Microsoft
(the statement does tend to hold true, though).

To alter the event, you should use the DOM 2 Event methods with
DOM-compliant browsers, and Mr Honnen's method with others. However, I
don't know how you would replace an event listener, other than by removing
the existing handler and then adding the new one.

Mike

--
Michael Winter
M.******@blueyonder.co.invalid (replace ".invalid" with ".uk" to reply)
Jul 20 '05 #6

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

Similar topics

2
by: Mark Durgee | last post by:
I have a "submit" button in a form that creates a record in my Filemaker database that works as it should. This is the HTML for it: <INPUT TYPE="SUBMIT" name="-New" VALUE="Add Record"> I...
1
by: Bill | last post by:
Hmmm... the onChange handler for radio buttons only seems to work when I click on the specific radio button. If I cause it to change - become unchecked - by clciking on another radio button in the...
1
by: MonkeyBoy | last post by:
I am doing some some HTML manipulation in client-side script (IE5.x and IE6.x browsers only). Something like.. var tmpHTML = oTable.outerHTML // do something to the HTML her oTable.outerHTML =...
8
by: Mattias Campe | last post by:
Hello, On http://student.ugent.be/astrid/bewoners.php I got the problem that I want Javascript to let my browser go to http://student.ugent.be/astrid/bewoners.php?beginAcjaar=2002 when I select...
1
by: Christoph | last post by:
I'm trying to validate some HTML form elements when the user tabs out of each element. However, I'm having some problems. It appears that the order of events is onChange followed some time...
2
by: DonD | last post by:
I have a form that allows a user to upload a file. When they select a file (onChange), I call a JS function that analyzes the filename for specific keywords and then populates a multiple select box...
3
by: jab3 | last post by:
Hello. I"m new to this group, and to JavaScript in general, so please forgive me if I breach local etiquette. I'm trying to implement some client-side 'dynamic' validation on a form. I'm having...
10
by: david.bercot | last post by:
Hi, I have a big problem with a simple event : onchange !!! If I write this page : <html> <body> <form id="vu"> <input id="var01" name="var01" size="5" onchange="return false;"/> </form>...
14
by: The Natural Philosopher | last post by:
This is a nasty one and I can't see my way out of it. I have a bunch of select statements in a form, and each select statement has an onchange="do_something(this)" in it, and this works...
6
by: James007 | last post by:
Hi everyone, I am developing a web page for an embedded application. I created a text box for entering a value (only 1 byte long). The onchange event triggers correctly when I enter the value...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
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: 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: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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.