Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Failing to get DIV content to flip between initial and alternate version

52 views
Skip to first unread message

$Bill

unread,
Jun 17, 2016, 2:19:05 AM6/17/16
to
I'm generating a TV Guide page from a Perl script to HTML and then rendering
the page. The HTML has the schedule in two formats: 1) grid; 2) list. What
I'm trying to do is show just the grid or just the list instead of both. The
default is grid type. The way I'm trying to implement this is by using
document.getElementById to get the DIV containing the HTML and
<element>.innerHTML = <newText> to set the alternate type of listing (grid/list).

The code works to actually change the content, but then seems to reload the page
reverting it back - alert popup in init shows it's being called once on load and
again on click of 'Flip View' button (which it shouldn't). How do I stop the
second load from happening?

TIA, Bill

My test case is below:


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">

<HTML>
<HEAD>
<TITLE>Flip Test</TITLE>
</HEAD>

<BODY>

<SCRIPT> // init global vars

var isGrid = 0; // cause a switch between grid text & list text
// isGrid == 0 means init, == 1 means grid active, == 2 means list active
var gridTxt = "<P>Grid Text</P>"; // just some test text
var listTxt = "<P>List Text</P>"; // just some test text
document.body.onload = init; // init to grid text

// function to swap grid and list content
function FlipType () {

// alert ("0: isGrid=" + isGrid); // debug
// get the current div object by id
var flipDiv = document.getElementById("FlipDiv");
// 1st execution on init doesn't get to here (init:, 0:)
// alert ("1: " + flipDiv.innerHTML); // debug
if (isGrid != 1) { // set to grid if not grid
flipDiv.innerHTML = gridTxt;
// alert ("2: " + flipDiv.innerHTML); // debug
isGrid = 1; // set flip switch to grid
} else { // else set to list
flipDiv.innerHTML = listTxt;
// alert ("3: " + flipDiv.innerHTML); // debug
isGrid = 2; // set flip switch to list
}
// alert ("4: isGrid=" + isGrid); // debug
// button click execution gets to here, but seems to re-call init like the page
// is re-loading ???
// 0:, 1:, 2: 4:, init:. 0:

}
// init calls FlipType to set initial grid text
function init () {
document.body.onload = null; // trying to prevent 2nd load
alert ("init: isGrid=" + isGrid); // getting called on button click-wrong
// if (isGrid == 1 || isGrid == 2) { ; } else { FlipType (); } this fails to work
FlipType (); // to set the text the first time to grid
}

</SCRIPT>

<!-- button to test FlipType -->
<FORM>
<!-- for some reason FlipType is executed twice when I click it ???
maybe the body is re-loading from onload ??? -->
<BUTTON onclick="FlipType()">Flip View</BUTTON>
</FORM>

<!-- actual code to flip goes inside this form in the DIV -->
<FORM>
<FORM METHOD="POST" ACTION="http://www.todbe.com/cgi-bin/prt_tv_sched.pl">
<BR><INPUT TYPE="HIDDEN" NAME="DATE" VALUE="20160612">
<DIV ID="FlipDiv"><P>Replace Me</P></DIV>
<BR><INPUT TYPE="SUBMIT" VALUE="Print Selected Schedule">
</FORM>

</BODY>
</HTML>


Evertjan.

unread,
Jun 17, 2016, 5:32:20 AM6/17/16
to
$Bill <ne...@todbe.com> wrote on 17 Jun 2016 in comp.lang.javascript:

> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
> "http://www.w3.org/TR/html4/loose.dtd">

<!DOCTYPE HTML> will do in the 21 century.

> <HTML>
> <HEAD>
> <TITLE>Flip Test</TITLE>
> </HEAD>
>
> <BODY>
>
> <SCRIPT> // init global vars
>
> var isGrid = 0; // cause a switch between grid text & list
> text // isGrid == 0 means init, == 1 means grid active, == 2 means list
> active var gridTxt = "<P>Grid Text</P>"; // just some test text
> var listTxt = "<P>List Text</P>"; // just some test text
> document.body.onload = init; // init to grid text

window.onload = init;

then you can set the <script> inside the <head>, where it belongs.

>
> // function to swap grid and list content
> function FlipType () {
>
> // alert ("0: isGrid=" + isGrid); // debug
> // get the current div object by id
> var flipDiv = document.getElementById("FlipDiv");
> // 1st execution on init doesn't get to here (init:, 0:)
> // alert ("1: " + flipDiv.innerHTML); // debug
> if (isGrid != 1) { // set to grid if not grid
> flipDiv.innerHTML = gridTxt;
> // alert ("2: " + flipDiv.innerHTML); // debug
> isGrid = 1; // set flip switch to grid
>} else { // else set to list
> flipDiv.innerHTML = listTxt;
> // alert ("3: " + flipDiv.innerHTML); // debug
> isGrid = 2; // set flip switch to list
>}
> // alert ("4: isGrid=" + isGrid); // debug
> // button click execution gets to here, but seems to re-call init like
> the page // is re-loading ???
> // 0:, 1:, 2: 4:, init:. 0:
>
>}
> // init calls FlipType to set initial grid text
> function init () {
> document.body.onload = null; // trying to prevent 2nd load

This is nonsense, a document always loads once, and then is a new document.


> alert ("init: isGrid=" + isGrid); // getting called on button
> click-wrong // if (isGrid == 1 || isGrid == 2) { ; } else { FlipType ();
> } this fails to work FlipType (); // to set the text
> the first time to grid
>}
>
> </SCRIPT>
>
> <!-- button to test FlipType -->
> <FORM>
> <!-- for some reason FlipType is executed twice when I click it ???
> maybe the body is re-loading from onload ??? -->
> <BUTTON onclick="FlipType()">Flip View</BUTTON>

The form is executed, so the page reloads and the javascript execution is
lost, so do a "return false" to prevent the form from executing:

<button onclick='flipType();return false;'>Flip View</button>

or set the <button> outside a <form>


> </FORM>
>
> <!-- actual code to flip goes inside this form in the DIV -->
> <FORM>
> <FORM METHOD="POST"
> ACTION="http://www.todbe.com/cgi-bin/prt_tv_sched.pl">
> <BR><INPUT TYPE="HIDDEN" NAME="DATE" VALUE="20160612">
> <DIV ID="FlipDiv"><P>Replace Me</P></DIV>
> <BR><INPUT TYPE="SUBMIT" VALUE="Print Selected Schedule">
> </FORM>
>
> </BODY>
> </HTML>

I prefer lowercase html, less screaming.

And leave out the copious commenting on usenet,
as the lines get too long.

Try this:

============================================
<!DOCTYPE HTML>
<html>
<head>
<title>Flip Test</title>
<script>
var isGrid = 0;
var gridTxt = '<p>Grid Text</p>';
var listTxt = '<p>List Text</p>';
function flipType() {
var flipDiv = document.getElementById('FlipDiv');
if (isGrid != 1) {
flipDiv.innerHTML = gridTxt;
isGrid = 1;
} else {
flipDiv.innerHTML = listTxt;
isGrid = 2;
};
};

function init() {
// document.body.onload = null;
// alert ('init: isGrid=' + isGrid);
flipType();
};
window.onload = init;
</script>
</head>

<body>
<form>
<button onclick='flipType();return false;'>Flip View</button>
</form>
<form>
<form method='post' action=''
<br><input type='hidden' name='date' value='20160612'>
<div id='FlipDiv'><p>Replace Me</p></div>
<br><input type='submit' value='Print Selected Schedule'>
</form>
</body>
</html>
===================================

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

$Bill

unread,
Jun 17, 2016, 10:00:34 PM6/17/16
to
On 6/17/2016 02:32, Evertjan. wrote:
> $Bill <ne...@todbe.com> wrote on 17 Jun 2016 in comp.lang.javascript:
>
> window.onload = init;
>
> then you can set the <script> inside the <head>, where it belongs.

>> document.body.onload = null; // trying to prevent 2nd load

> This is nonsense, a document always loads once, and then is a new document.

What do you expect on my first try at using Javascript? ;)

> The form is executed, so the page reloads and the javascript execution is
> lost, so do a "return false" to prevent the form from executing:
>
> <button onclick='flipType();return false;'>Flip View</button>
>
> or set the <button> outside a <form>

I knew there had to be a way to do that - just hadn't found it yet.
Didn't realize that the form execution was causing the re-load.

> I prefer lowercase html, less screaming.

I just normally UC the HTML tags.

> And leave out the copious commenting on usenet,
> as the lines get too long.

That was for the benefit of the post to explain what I thought I
was doing/trying to do.

> Try this:

Much grass amigo. That works like a charm. Now I need to slip all
the actual HTML into those two vars ...


Evertjan.

unread,
Jun 18, 2016, 5:35:53 AM6/18/16
to
$Bill <ne...@todbe.com> wrote on 18 Jun 2016 in comp.lang.javascript:

>>> document.body.onload = null; // trying to prevent 2nd load
>
>> This is nonsense, a document always loads once, and then is a new
>> document.
>
> What do you expect on my first try at using Javascript? ;)

I am critisizing factual code, not your coding.

And the coding is illogical, whether you are a novice or an expert.

This NG is not about examination of people, but of Javascript code.

> Much grass amigo. That works like a charm. Now I need to slip all>
> the actual HTML into those two vars ..

Success.

Michael Haufe (TNO)

unread,
Jun 18, 2016, 1:59:12 PM6/18/16
to
On Friday, June 17, 2016 at 4:32:20 AM UTC-5, Evertjan. wrote:

> then you can set the <script> inside the <head>, where it belongs.

No.

It should be placed right before </body> to make the onload redundant, and to allow the page to render faster. Also an explicit type attribute should be provided.

Stanimir Stamenkov

unread,
Jun 18, 2016, 3:17:42 PM6/18/16
to
Fri, 17 Jun 2016 11:32:18 +0200, /Evertjan./:
> $Bill wrote on 17 Jun 2016 in comp.lang.javascript:
>
>> <!-- button to test FlipType -->
>> <FORM>
>> <!-- for some reason FlipType is executed twice when I click it ???
>> maybe the body is re-loading from onload ??? -->
>> <BUTTON onclick="FlipType()">Flip View</BUTTON>
>
> The form is executed, so the page reloads and the javascript execution is
> lost, so do a "return false" to prevent the form from executing:
>
> <button onclick='flipType();return false;'>Flip View</button>
>
> or set the <button> outside a <form>

Or use <button type="button" onclick="filtType()">Flip View</button>.

--
Stanimir

Stanimir Stamenkov

unread,
Jun 18, 2016, 3:32:43 PM6/18/16
to
Sat, 18 Jun 2016 10:59:03 -0700 (PDT), /Michael Haufe (TNO)/:
> On Friday, June 17, 2016 at 4:32:20 AM UTC-5, Evertjan. wrote:
>
>> then you can set the <script> inside the <head>, where it belongs.
>
> No.
>
> ... Also an explicit type attribute should be provided.

As someone else has written in this thread, <script> will do in the
21 century. If the type is "text/javascript" specifying it is
pretty much redundant, and all examples I'm seeing in latest
specifications do not use 'type' attribute, if not necessary:

https://www.w3.org/TR/html5/scripting-1.html#the-script-element

(search for "<script" w/o quotes on the page)

--
Stanimir

Michael Haufe (TNO)

unread,
Jun 18, 2016, 4:51:04 PM6/18/16
to
I would agree with you in principle only if the following is no longer considered valid and is ignored in HTML5:

<https://www.w3.org/TR/html4/interact/scripts.html#h-18.2.2>

Also, contingent on downrev browser behavior. For instance, even though older IE versions would trigger strict mode when seeing the new doctype, they may indeed still follow the legacy algorithm for determining script type.

How many browsers are considered 100% HTML5 compliant right now anyway? Not that they would need to be of course, but in this particular case I haven't seen any stats one way or another on whether this is implemented.

$Bill

unread,
Jun 18, 2016, 10:16:27 PM6/18/16
to
On 6/18/2016 02:35, Evertjan. wrote:
> $Bill <ne...@todbe.com> wrote on 18 Jun 2016 in comp.lang.javascript:
>
>>>> document.body.onload = null; // trying to prevent 2nd load
>>
>>> This is nonsense, a document always loads once, and then is a new
>>> document.
>>
>> What do you expect on my first try at using Javascript? ;)
>
> I am critisizing factual code, not your coding.
>
> And the coding is illogical, whether you are a novice or an expert.

But an expert would know that and what I was attempting to do was
indeed logical - just didn't know how to render the logic. :)

> This NG is not about examination of people, but of Javascript code.
>
>> Much grass amigo. That works like a charm. Now I need to slip all>
>> the actual HTML into those two vars ..
>
> Success.

Yes. Still needs some tweaking on some tables, but the concept is working.
Thanks again for the help.

Stanimir Stamenkov

unread,
Jun 19, 2016, 2:40:42 AM6/19/16
to
Sat, 18 Jun 2016 13:50:58 -0700 (PDT), /Michael Haufe (TNO)/:
> On Saturday, June 18, 2016 at 2:32:43 PM UTC-5, Stanimir Stamenkov wrote:
>
>> As someone else has written in this thread, <script> will do in the
>> 21 century. If the type is "text/javascript" specifying it is
>> pretty much redundant, and all examples I'm seeing in latest
>> specifications do not use 'type' attribute, if not necessary:
>>
>> https://www.w3.org/TR/html5/scripting-1.html#the-script-element
>>
>> (search for "<script" w/o quotes on the page)
>
> I would agree with you in principle only if the following is no
> longer considered valid and is ignored in HTML5:
>
> <https://www.w3.org/TR/html4/interact/scripts.html#h-18.2.2>

"As HTML does not rely on a specific scripting language, document
authors must explicitly tell user agents the language of each script."

I suspect this has never been true in reality. JavaScript has ever
been the only scripting language on the Web.

> Also, contingent on downrev browser behavior. For instance, even
> though older IE versions would trigger strict mode when seeing
> the new doctype, they may indeed still follow the legacy
> algorithm for determining script type.

If one has to support older browser versions it would need to be
tested, and adjusted if not really working there. Have you
experienced a case/browser where it is not working?

> How many browsers are considered 100% HTML5 compliant right now
> anyway? Not that they would need to be of course, but in this
> particular case I haven't seen any stats one way or another on
> whether this is implemented.

I'm speculating it is implemented in all recent version browsers,
and probably supported by older version browsers, but I would like
to see some representative stats, also.

--
Stanimir

Doc O'Leary

unread,
Jun 19, 2016, 10:23:50 AM6/19/16
to
For your reference, records indicate that
$Bill <ne...@todbe.com> wrote:

> But an expert would know that and what I was attempting to do was
> indeed logical

No, there’s really no logic in screwing with innerHTML in order to get the job done. An expert would do something more sane, like altering the CSS display property of the elements in question.

--
"Also . . . I can kill you with my brain."
River Tam, Trash, Firefly


Michael Haufe (TNO)

unread,
Jun 19, 2016, 3:21:27 PM6/19/16
to
On Sunday, June 19, 2016 at 1:40:42 AM UTC-5, Stanimir Stamenkov wrote:

> "As HTML does not rely on a specific scripting language, document
> authors must explicitly tell user agents the language of each script."
>
> I suspect this has never been true in reality. JavaScript has ever
> been the only scripting language on the Web.

That is just simply false. Internet Explorer versions below 11 support type="text/vbscript" and IE 11 also supports it in compatibility mode. This support is extensible and on a number of Windows machines you can find other languages added (such as Perl). Usually for use in *.hta applications, but once registered, the functionality is available for the regular browser as well. (Both leverage mshtml.dll)

In Firefox, you can trigger different versions of JavaScript explicitly (incompatible with the ECMAScript standard), for example:

type="application/javascript;version=1.8"

Mozilla also experimented with Python embedding for a short period. There is also the skulpt project which tries to do the same.

Let's also not forget the existence of 3D on the web which utilizes:

type="x-shader/x-vertex"

and

type="x-shader/x-fragment"

So while yes, it will PROBABLY be JavaScript if you leave the type attribute implicit, Wouldn't you prefer to have a guarantee by being explicit about your intent?

> If one has to support older browser versions it would need to be
> tested, and adjusted if not really working there. Have you
> experienced a case/browser where it is not working?

Do you only develop for an evergreen browser? If not than you are always supporting an older browser.

Have I experience issues with this behavior? Yes, perhaps a dozen times. Often this has been due to upgrading a website while still leveraging existing server infrastructure (which will send unexpected headers to the client), other times due to the necessity of developing larger enterprise applications which extend across intranets and extranets, which gives you a very large range of browsers you have to support.

This is one less thing to test if you are explicit, and is also future proof when the standards change again.

> I'm speculating it is implemented in all recent version browsers,
> and probably supported by older version browsers, but I would like
> to see some representative stats, also.

Explicit Is Better Than Implicit (EIBTI) in this case. I don't need to test for edge cases, and don't need to see statistics.

$Bill

unread,
Jun 20, 2016, 7:13:16 AM6/20/16
to
On 6/19/2016 07:23, Doc O'Leary wrote:
> For your reference, records indicate that
> $Bill <ne...@todbe.com> wrote:
>
>> But an expert would know that and what I was attempting to do was
>> indeed logical
>
> No, there’s really no logic in screwing with innerHTML in order to get the job done. An expert would do something more sane, like altering the CSS display property of the elements in question.

You're wrong - the logic is there, the knowledge of the language/workings isn't.
And I'm a neophyte not an expert - what I did got the job done - when I have the
knowledge, I'll find better/more apropos ways to do things.

$Bill

unread,
Jun 20, 2016, 7:16:54 AM6/20/16
to
BTW, if you have a better way to do it, feel free to show it instead of complaining
about my lack of JS knowledge. This is supposed to be a learning environment.

Evertjan.

unread,
Jun 25, 2016, 10:40:55 AM6/25/16
to
$Bill <ne...@todbe.com> wrote on 19 Jun 2016 in comp.lang.javascript:

>>> What do you expect on my first try at using Javascript? ;)
>>
>> I am critisizing factual code, not your coding.
>>
>> And the coding is illogical, whether you are a novice or an expert.
>
> But an expert would know that and what I was attempting to do was
> indeed logical - just didn't know how to render the logic. :)

Please consider arguments, not authority, as then you would need arguments
to define the specific authority.

And again, I did not criticize what you were doing, but the code.

If you did know how to render the code, the logic of the submitted code
would not change.

> Yes. Still needs some tweaking on some tables,
> but the concept is working.
> Thanks again for the help.

"Working" seems to me not about concepts.

Sorry for teasing you, Bill, it is irresistable.

Evertjan.

unread,
Jun 25, 2016, 10:45:55 AM6/25/16
to
Stanimir Stamenkov <s7a...@netscape.net> wrote on 18 Jun 2016 in
comp.lang.javascript:
Right you are, but it does not "feel" right
that a button inside a form is not a button by default.

Christoph M. Becker

unread,
Jun 25, 2016, 11:17:10 AM6/25/16
to
On 25.06.2016 at 16:45, Evertjan. wrote:

> Stanimir Stamenkov <s7a...@netscape.net> wrote on 18 Jun 2016 in
> comp.lang.javascript:
>
>> Or use <button type="button" onclick="filtType()">Flip View</button>.
>
> Right you are, but it does not "feel" right
> that a button inside a form is not a button by default.

The default value of the type attribute of a button is submit. IMO,
that's particularly useful, if the button is a child of a form.

--
Christoph M. Becker

Thomas 'PointedEars' Lahn

unread,
Jun 25, 2016, 12:36:30 PM6/25/16
to
Stanimir Stamenkov wrote:

> Sat, 18 Jun 2016 13:50:58 -0700 (PDT), /Michael Haufe (TNO)/:
>> I would agree with you in principle only if the following is no
>> longer considered valid and is ignored in HTML5:
>>
>> <https://www.w3.org/TR/html4/interact/scripts.html#h-18.2.2>
>
> "As HTML does not rely on a specific scripting language, document
> authors must explicitly tell user agents the language of each script."
>
> I suspect this has never been true in reality.

It has been.

> JavaScript has ever been the only scripting language on the Web.

No, nor is it the only scripting language now (even the fact aside that
there is not only one “JavaScript”, nor does “JavaScript” refer to all
ECMAScript implementations in use in browsers). The supported ECMAScript
implementation is only the default scripting language since HTML5
(2014-10-28).

<https://www.w3.org/TR/2014/REC-html5-20141028/scripting-1.html#scriptingLanguages>

There is no harm in specifying the default scripting language in HTML5
explicitly, though.

>> Also, contingent on downrev browser behavior. For instance, even
>> though older IE versions would trigger strict mode when seeing
>> the new doctype, they may indeed still follow the legacy
>> algorithm for determining script type.
>
> If one has to support older browser versions it would need to be
> tested, and adjusted if not really working there. Have you
> experienced a case/browser where it is not working?

Yes.

>> How many browsers are considered 100% HTML5 compliant right now
>> anyway? Not that they would need to be of course, but in this
>> particular case I haven't seen any stats one way or another on
>> whether this is implemented.
>
> I'm speculating it is implemented in all recent version browsers,
> and probably supported by older version browsers, but I would like
> to see some representative stats, also.

There are a test case and some (old) results at
<http://wayback.archive.org/web/20100904140711/http://pointedears.de/scripts/test/mime-types/> whose revival and update is still on my to-do list.

--
PointedEars
FAQ: <http://PointedEars.de/faq> | SVN: <http://PointedEars.de/wsvn/>
Twitter: @PointedEars2 | ES Matrix: <http://PointedEars.de/es-matrix>
Please do not cc me. / Bitte keine Kopien per E-Mail.

Thomas 'PointedEars' Lahn

unread,
Jun 25, 2016, 12:38:02 PM6/25/16
to
Stanimir Stamenkov wrote:

> Sat, 18 Jun 2016 13:50:58 -0700 (PDT), /Michael Haufe (TNO)/:
>> I would agree with you in principle only if the following is no
>> longer considered valid and is ignored in HTML5:
>>
>> <https://www.w3.org/TR/html4/interact/scripts.html#h-18.2.2>
>
> "As HTML does not rely on a specific scripting language, document
> authors must explicitly tell user agents the language of each script."
>
> I suspect this has never been true in reality.

It has been.

> JavaScript has ever been the only scripting language on the Web.

No, nor is it the only scripting language now (even the fact aside that
there is not only one “JavaScript”, nor does “JavaScript” refer to all
ECMAScript implementations in use in browsers). The supported ECMAScript
implementation is only the default scripting language since HTML5
(2014-10-28).

<https://www.w3.org/TR/2014/REC-html5-20141028/scripting-1.html#scriptingLanguages>
<https://www.w3.org/TR/2014/REC-html5-20141028/scripting-1.html#attr-script-type>

There is no harm in specifying the default scripting language in HTML5
explicitly, though.

>> Also, contingent on downrev browser behavior. For instance, even
>> though older IE versions would trigger strict mode when seeing
>> the new doctype, they may indeed still follow the legacy
>> algorithm for determining script type.
>
> If one has to support older browser versions it would need to be
> tested, and adjusted if not really working there. Have you
> experienced a case/browser where it is not working?

Yes.

>> How many browsers are considered 100% HTML5 compliant right now
>> anyway? Not that they would need to be of course, but in this
>> particular case I haven't seen any stats one way or another on
>> whether this is implemented.
>
> I'm speculating it is implemented in all recent version browsers,
> and probably supported by older version browsers, but I would like
> to see some representative stats, also.

Evertjan.

unread,
Jun 25, 2016, 1:03:04 PM6/25/16
to
"Christoph M. Becker" <cmbec...@arcor.de> wrote on 25 Jun 2016 in
comp.lang.javascript:
Quite, if you think/feel error-proneness equals usefulness.

Evertjan.

unread,
Jun 26, 2016, 6:53:41 AM6/26/16
to
Please don't see arguments against your idea as arguments against you.

You will see, imho, that discussions will start to be a joy in themselves.

$Bill

unread,
Jun 26, 2016, 7:22:42 PM6/26/16
to
On 6/26/2016 03:53, Evertjan. wrote:
>
> Please don't see arguments against your idea as arguments against you.

Criticism with no constructive return/alternate information is useless/destructive.
He had no argument other than don't do it that way (even though it worked for you).

> You will see, imho, that discussions will start to be a joy in themselves.

You're a joy in just your being.

Thomas 'PointedEars' Lahn

unread,
Jun 26, 2016, 11:43:30 PM6/26/16
to
He told you what he thinks you should do. Which part of it do you not
understand? See the FAQ.

In this case, however, I think you should switch the versions by making an
HTTP request and changing the content accordingly, either with XHR in the
background or with the classic approach of passing a parameter to the
server-side script, *because the data of a TV Guide can have changed in the
meantime*.

The former might be what you are up to; depending on the complexity of the
presentation, indeed it might be better to request the HTML instead of just
JSON, and replace the relevant markup instead of individual parts from the
JSON data. In the case of a table, you should then rewrite the whole table
using the “innerHTML” property as that appears to be much faster than the
alternatives.

<http://www.quirksmode.org/dom/innerhtml.html>

Note that the results there are *old*, so do your own tests with “Test now”.

And get a real name if you want to be taken seriously here. That goes to
all of you – this is _not_ a chat room.

John Harris

unread,
Jun 27, 2016, 4:38:38 AM6/27/16
to
On Mon, 27 Jun 2016 05:43:24 +0200, Thomas 'PointedEars' Lahn
<Point...@web.de> wrote:


<snip>
>And get a real name if you want to be taken seriously here. That goes to
>all of you – this is _not_ a chat room.

But Thomas said earlier :
> you do not substantiate your claim, so we can safely assume it is
> nonsense based on wishful thinking and insufficient testing.

John

Evertjan.

unread,
Jun 27, 2016, 4:49:58 AM6/27/16
to
$Bill <ne...@todbe.com> wrote on 27 Jun 2016 in comp.lang.javascript:

> On 6/26/2016 03:53, Evertjan. wrote:
>>
>> Please don't see arguments against your idea as arguments against you.
>
> Criticism with no constructive return/alternate information is
> useless/destructive.

Why is uselessnes destructive?
Why should responses be usefull?
After all, the measure of usefullness depends on the reader.

> He had no argument other than don't do it that way

Even if so, I don't remember and want to,
don't mistake that as critisism on your person.

> (even though it worked for you).

I don't indulge in slavery. ;-)

>> You will see, imho, that discussions will start to be a joy in
>> themselves.
>
> You're a joy in just your being.

"Makarioi hoi ptochoi to pneumati"?

Evertjan.

unread,
Jun 27, 2016, 5:01:36 AM6/27/16
to
John Harris <ni...@jghnorth.org.uk.invalid> wrote on 27 Jun 2016 in
comp.lang.javascript:

> But Thomas said earlier :
>> you do not substantiate your claim, so we can safely assume it is
>> nonsense based on wishful thinking and insufficient testing.

Wishful thinking can become true:
"I think the sun will come up tomorrow again!"

"insufficient" in whose eyes?

> <ni...@jghnorth.org.uk.invalid>

Lacking wishfull thinking,
perhaps change that to the fully tested:

<ni...@jghnorth.org.uk.brexit>

Doc O'Leary

unread,
Jun 27, 2016, 9:58:42 AM6/27/16
to
For your reference, records indicate that
$Bill <ne...@todbe.com> wrote:

> He had no argument other than don't do it that way (even though it worked for you).

I told you to use CSS. I told you the specific property to set. What
more are you *demanding* that I do for you? If you don’t have the
gumption to do any of the dirty work yourself, don’t post to an
international forum asking for help. If you need someone to do all
the work for you, hire an employee.

John Harris

unread,
Jun 28, 2016, 5:04:53 AM6/28/16
to
On Mon, 27 Jun 2016 11:00:55 +0200, "Evertjan."
<exxjxw.h...@inter.nl.net> wrote:

>John Harris <ni...@jghnorth.org.uk.invalid> wrote on 27 Jun 2016 in
>comp.lang.javascript:
>
>> But Thomas said earlier :
>>> you do not substantiate your claim, so we can safely assume it is
>>> nonsense based on wishful thinking and insufficient testing.
>
>Wishful thinking can become true:
>"I think the sun will come up tomorrow again!"
>
>"insufficient" in whose eyes?
<snip>

Are you sure you're permitted to criticise what Thomas has said ?

John

Evertjan.

unread,
Jun 28, 2016, 6:14:05 AM6/28/16
to
John Harris <ni...@jghnorth.org.uk.invalid> wrote on 28 Jun 2016 in
comp.lang.javascript:
This is not a Q of permission, but of reasonable behavour.

Criticizing a person is bad and in a way nonsensical.

Criticizing ideas is a must.

Criticizing ideas should be done following probable/perceived facts and
logical thinking, while stearing clear of authority or dogma.

> what Thomas has said ?

The ideas of Thomas should be met with the same scepticism,
but there is no need of criticizing his person.

> org.uk.invalid>

Still "invalid" in stead of "brexit"?
Ah, "Harris", you are a Scottish lad, I presume.

John Harris

unread,
Jun 29, 2016, 11:16:48 AM6/29/16
to
On Tue, 28 Jun 2016 12:13:59 +0200, "Evertjan."
<exxjxw.h...@inter.nl.net> wrote:

>John Harris <ni...@jghnorth.org.uk.invalid> wrote on 28 Jun 2016 in
>comp.lang.javascript:

<snip>
>> org.uk.invalid>
>
>Still "invalid" in stead of "brexit"?
>Ah, "Harris", you are a Scottish lad, I presume.

... or London, or Gibraltar, or one of several other places.

John

Evertjan.

unread,
Jun 29, 2016, 1:48:23 PM6/29/16
to
John Harris <ni...@jghnorth.org.uk.invalid> wrote on 29 Jun 2016 in
comp.lang.javascript:
Quite.
0 new messages