What's wrong with the following code? Thanks

D

Don Li

No err msg but not working.

var tbl=document.getElementById('notesdetail');var
nrow=tbl.insertRow(0);var
c1=nrow.insertCell(0);c1.id='newdata';document.getElementById('newdata').value=document.getElementById('notes').value;

<form id="edit" style="display:none">
<textarea id="notes" name="notes" cols="50" rows="7">hot potato</
textarea><br/>
<input type="button" value="Add to top" onclick="//psueduo code, run
the above js">
</form>

<table id="notesdetail" style="display:none">
<tbody>
<!-- a new row should be inserted here --->
<tr>
<td valign="top"><b>abc</b></td>
<td>abc in detail</td>
</tr>
</tbody>
</table>
 
E

Evertjan.

Don Li wrote on 21 mrt 2008 in comp.lang.javascript:
No err msg but not working.

var tbl=document.getElementById('notesdetail');var
nrow=tbl.insertRow(0);var
c1=nrow.insertCell(0);c1.id='newdata';

document.getElementById('newdata').value=
document.getElementById('notes').value;

The content of a tablecell is not .value
but .innerHTML or [IE] .innerText


Why not simply skip the .id and use:

c1.innerHTML = document.getElementById('notes').value;

You could even use the DOM here:

c1.appendChild(document.createTextNode(document.getElementById
('notes').value));
 
D

Don Li

Don Li wrote on 21 mrt 2008 in comp.lang.javascript:
No err msg but not working.
var tbl=document.getElementById('notesdetail');var
nrow=tbl.insertRow(0);var
c1=nrow.insertCell(0);c1.id='newdata';
document.getElementById('newdata').value=
document.getElementById('notes').value;

The content of a tablecell is not .value
but .innerHTML or [IE] .innerText

Why not simply skip the .id and use:

c1.innerHTML = document.getElementById('notes').value;

You could even use the DOM here:

c1.appendChild(document.createTextNode(document.getElementById
('notes').value));




<form id="edit" style="display:none">
<textarea id="notes" name="notes" cols="50" rows="7">hot potato</
textarea><br/>
<input type="button" value="Add to top" onclick="//psueduo code, run
the above js">
</form>
<table id="notesdetail" style="display:none">
<tbody>
<!-- a new row should be inserted here --->
<tr>
<td valign="top"><b>abc</b></td>
<td>abc in detail</td>
</tr>
</tbody>
</table>

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)- Hide quoted text -

- Show quoted text -

Great. Thank you. But why did the language designer use both to get
the same result?
Is it because innerHTML would always provide the most current value?
 
D

Don Li

Don Li wrote on 21 mrt 2008 in comp.lang.javascript:
No err msg but not working.
var tbl=document.getElementById('notesdetail');var
nrow=tbl.insertRow(0);var
c1=nrow.insertCell(0);c1.id='newdata';
document.getElementById('newdata').value=
document.getElementById('notes').value;

The content of a tablecell is not .value
but .innerHTML or [IE] .innerText

Why not simply skip the .id and use:

c1.innerHTML = document.getElementById('notes').value;

You could even use the DOM here:

c1.appendChild(document.createTextNode(document.getElementById
('notes').value));




<form id="edit" style="display:none">
<textarea id="notes" name="notes" cols="50" rows="7">hot potato</
textarea><br/>
<input type="button" value="Add to top" onclick="//psueduo code, run
the above js">
</form>
<table id="notesdetail" style="display:none">
<tbody>
<!-- a new row should be inserted here --->
<tr>
<td valign="top"><b>abc</b></td>
<td>abc in detail</td>
</tr>
</tbody>
</table>

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)- Hide quoted text -

- Show quoted text -

Oh, a minor question, thought
c1.style.valign="top";
was working, but no. How come? IE7. Thanks.
 
J

Joost Diepenmaat

Don Li said:
Oh, a minor question, thought
c1.style.valign="top";
was working, but no. How come? IE7. Thanks.

That probably doesn't work anywhere, since valign isn't a valid style
property.
 
D

Don Li

That probably doesn't work anywhere, since valign isn't a valid style
property.

So, how can I do that? Get valign="top" for the newly created cell?
Thanks.
 
E

Evertjan.

Don Li wrote on 21 mrt 2008 in comp.lang.javascript:

[please do not quote signatures on usenet]
Great. Thank you. But why did the language designer use both to get
the same result?

There is not such a thing as a javascript "Creator",
nor of a javascript Religion,
it is more like an more or less intelligent design by many,
and those many did not aggree usually.

And then:

The above are browser matters,
like the DOM not part of javascript as a language.

The DOM can also be used buy other languages, like VBscript in the IE.
Is it because innerHTML would always provide the most current value?

"most current value", what is that?

innerHTML does not fit the DOM structure.

innerHTML suggests that the DOM still exists as a HTML string of the page,
which is a false suggestion.

A textnode is not the or a value of it's container,

In the DOM sense a parent can contain many childnodes.
 
E

Evertjan.

Joost Diepenmaat wrote on 21 mrt 2008 in comp.lang.javascript:
That probably doesn't work anywhere, since valign isn't a valid style
property.

In the last century we used:

c1.valign="top";

In this one perhaps in CSS:

c1.style.verticalAlign="top";

Joost mag het weten why.
 
D

Don Li

Joost Diepenmaat wrote on 21 mrt 2008 in comp.lang.javascript:



In the last century we used:

c1.valign="top";

In this one perhaps in CSS:

c1.style.verticalAlign="top";

Joost mag het weten why.

"This century" works with IE7, haven't tested it against other
browsers while "last century" was a mess.

Translation: Just imagine why?

Thanks. Also, for improving Use Experience, how do I get started with
the core elements of javascript, DOM? too MS? can't even think loud
on a subject that I'm shaky...
 
E

Evertjan.

Don Li wrote on 21 mrt 2008 in comp.lang.javascript:

[please do not quote signatures on usenet, signature removed]
"This century" works with IE7, haven't tested it against other
browsers while "last century" was a mess.

Translation: Just imagine why?

Only in the sense that "Just[us]/Joost" is the devil, sorry Joost.
The Dutch version is a [only originally felt profane] proverb.
Thanks. Also, for improving Use Experience, how do I get started with
the core elements of javascript, DOM? too MS? can't even think loud
on a subject that I'm shaky...

DOM is NOT a core element of javascript, it has nothing to do with the
javascript core, any other implemented browser script language can
probably use the DOM.
 
D

Don Li

Don Li wrote on 21 mrt 2008 in comp.lang.javascript:





[please do not quote signatures on usenet, signature removed]
"This century" works with IE7, haven't tested it against other
browsers while "last century" was a mess.
Translation: Just imagine why?

Only in the sense that "Just[us]/Joost" is the devil, sorry Joost.
The Dutch version is a [only originally felt profane] proverb.
Thanks.  Also, for improving Use Experience, how do I get started with
the core elements of javascript, DOM? too MS?  can't even think loud
on a subject that I'm shaky...

DOM is NOT a core element of javascript, it has nothing to do with the
javascript core, any other implemented browser script language can
probably use the DOM.

- Show quoted text -

Great, thank you. Now, I got another weird thing here, the screen has
two block elements, namely,
one form ID and the other table ID while the page has some unnamed
tables too.

Two js-triggered functions, upon clicking a close b (making it
display="none") regardless of its current state. so, I thought,
passing the argument of req to event trigger would do the trick,

if (req == "b")
{
document.getElementById('a').style.display='none';
}
else
{
document.getElementById('b').style.display='none';
}
 
T

Thomas 'PointedEars' Lahn

Don said:
Don Li wrote on 21 mrt 2008 in comp.lang.javascript:
No err msg but not working.
var tbl=document.getElementById('notesdetail');var
nrow=tbl.insertRow(0);var
c1=nrow.insertCell(0);c1.id='newdata';
document.getElementById('newdata').value=
document.getElementById('notes').value;
The content of a tablecell is not .value
but .innerHTML or [IE] .innerText

Why not simply skip the .id and use:

c1.innerHTML = document.getElementById('notes').value;

You could even use the DOM here:

The *W3C* DOM. `innerHTML' is also a DOM feature, introduced by the MSHTML DOM.
c1.appendChild(document.createTextNode(document.getElementById
('notes').value));
[...]

Please stop full-quoting.
Great. Thank you. But why did the language designer use both to get
the same result? [

They did not. A DOM is an API that is not part of the programming language.
Is it because innerHTML would always provide the most current value?

No. `innerHTML' is a proprietary feature; the W3C DOM is a Web standard.


PointedEars
 
D

Don Li

Great.  Thank you.  But why did the language designer use both to get
the same result? [

They did not.  A DOM is an API that is not part of the programming language.
Is it because innerHTML would always provide the most current value?

No.  `innerHTML' is a proprietary feature; the W3C DOM is a Web standard..
"proprietary" by whom? Looks like IE. Ok, so, W3C adopted MSHTML DOM
as one of its own.

Thanks. But wait, how come this W3C doc, url,
http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/def-index.html,
does not include reference to innerHTML?
 
D

Don Li

Great, thank you.  Now, I got another weird thing here, the screen has
two block elements, namely,
one form ID and the other table ID while the page has some unnamed
tables too.

Two js-triggered functions, upon clicking a close b (making it
display="none") regardless of its current state.  so, I thought,
passing the argument of req to event trigger would do the trick,

if (req == "b")
        {
        document.getElementById('a').style.display='none';
        }
        else
        {
        document.getElementById('b').style.display='none';
        }- Hide quoted text -

- Show quoted text -

Never mind, silly me, the second time when I looked at it I spotted
the problem.
 
T

Thomas 'PointedEars' Lahn

Don said:
Great. Thank you. But why did the language designer use both to get
the same result? [
They did not. A DOM is an API that is not part of the programming language.
Is it because innerHTML would always provide the most current value?
No. `innerHTML' is a proprietary feature; the W3C DOM is a Web standard.
"proprietary" by whom? Looks like IE.

Yes, the feature was introduced by the MSHTML DOM.
Ok, so, W3C adopted MSHTML DOM as one of its own.

Nonsense. You are using *two* APIs here.
Thanks. But wait, how come this W3C doc, url,
http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/def-index.html,
does not include reference to innerHTML?

Because you are citing a Working Draft, and you are mistaken anyway.


PointedEars
 
D

Don Li

Thanks.  But wait, how come this W3C doc, url,
Because you are citing a Working Draft, and you are mistaken anyway.
The name of "Working" is indeed misleading. It should be called Draft.
 
T

Thomas 'PointedEars' Lahn

Don said:
The name of "Working" is indeed misleading. It should be called Draft.

Nonsense. A Working Draft is not a working Draft.


PointedEars
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top