Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > alt.computer > #10648 > unrolled thread
| Started by | Paul <nospam@needed.invalid> |
|---|---|
| First post | 2018-01-02 04:26 -0500 |
| Last post | 2018-01-12 21:39 -0800 |
| Articles | 13 — 2 participants |
Back to article view | Back to alt.computer
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: javascript help, please Paul <nospam@needed.invalid> - 2018-01-02 04:26 -0500
Re: javascript help, please Robert Baer <robertbaer@localnet.com> - 2018-01-02 13:56 -0800
Re: javascript help, please Paul <nospam@needed.invalid> - 2018-01-02 18:18 -0500
Re: javascript help, please Robert Baer <robertbaer@localnet.com> - 2018-01-07 16:24 -0800
Re: javascript help, please Robert Baer <robertbaer@localnet.com> - 2018-01-09 22:23 -0800
Re: javascript help, please Paul <nospam@needed.invalid> - 2018-01-10 03:44 -0500
Re: javascript help, please Paul <nospam@needed.invalid> - 2018-01-10 22:44 -0500
Re: javascript help, please Paul <nospam@needed.invalid> - 2018-01-12 02:49 -0500
Re: javascript help, please Robert Baer <robertbaer@localnet.com> - 2018-01-12 21:10 -0800
Re: javascript help, please Paul <nospam@needed.invalid> - 2018-01-12 03:00 -0500
Re: javascript help, please Robert Baer <robertbaer@localnet.com> - 2018-01-12 21:16 -0800
Re: javascript help, please Paul <nospam@needed.invalid> - 2018-01-12 04:29 -0500
Re: javascript help, please Robert Baer <robertbaer@localnet.com> - 2018-01-12 21:39 -0800
| From | Paul <nospam@needed.invalid> |
|---|---|
| Date | 2018-01-02 04:26 -0500 |
| Subject | Re: javascript help, please |
| Message-ID | <p2fj8s$1k7$1@dont-email.me> |
Robert Baer wrote:
> One question inside the program; (new line)?
>
> The other is: how in the heck does one get an "if" to work (that
> second document.write() does not execute when that if exists).
>
> Thanks.
>
>
> ---
> This email has been checked for viruses by Avast antivirus software.
> https://www.avast.com/antivirus
https://stackoverflow.com/questions/5758161/how-do-i-create-a-new-line-in-javascript
Use the \n for a newline character.
document.write("\n");
However, if this is rendering to HTML, you will want to use the HTML tag for a newline:
document.write("<br>");
Don't ask me what that means though - what is this "rendering" thing ?
*******
A quick Google on "if then else" shows two examples.
if (hour < 18) {
greeting = "Good day";
}
if (hour < 18) {
greeting = "Good day";
} else {
greeting = "Good evening";
}
HTH,
Paul
[toc] | [next] | [standalone]
| From | Robert Baer <robertbaer@localnet.com> |
|---|---|
| Date | 2018-01-02 13:56 -0800 |
| Message-ID | <%dT2C.171281$gy4.4948@fx35.iad> |
| In reply to | #10648 |
Paul wrote:
> Robert Baer wrote:
>> One question inside the program; (new line)?
>>
>> The other is: how in the heck does one get an "if" to work (that
>> second document.write() does not execute when that if exists).
>>
>> Thanks.
>>
>>
>> ---
>> This email has been checked for viruses by Avast antivirus software.
>> https://www.avast.com/antivirus
>
> https://stackoverflow.com/questions/5758161/how-do-i-create-a-new-line-in-javascript
>
>
> Use the \n for a newline character.
>
> document.write("\n");
>
> However, if this is rendering to HTML, you will want to use the HTML
> tag for a newline:
>
> document.write("<br>");
>
> Don't ask me what that means though - what is this "rendering" thing ?
>
> *******
>
> A quick Google on "if then else" shows two examples.
>
> if (hour < 18) {
> greeting = "Good day";
> }
>
> if (hour < 18) {
> greeting = "Good day";
> } else {
> greeting = "Good evening";
> }
>
> HTH,
> Paul
Well, i had seen \n used for new line before, so i mistakenly thought
it would work.
It does not (look at the code).
The <br> DOES work; thanks.
Naturally, the Google "example" are non-sequitur.
Thanks.
[toc] | [prev] | [next] | [standalone]
| From | Paul <nospam@needed.invalid> |
|---|---|
| Date | 2018-01-02 18:18 -0500 |
| Message-ID | <p2h3vh$u2p$1@dont-email.me> |
| In reply to | #10648 |
Robert Baer wrote:
> Paul wrote:
>> The other is: how in the heck does one get an "if" to work (that
>> second document.write() does not execute when that if exists).
> OOPS; forgot to ask the above question WRT same program (attached).
>
I don't see anything wrong with your code.
It looks to me like it should have executed
both document.write statements.
And the thing is, you can only do so much by adding
print statements to a program, before you need help.
*******
You can use a debugger. Good luck with this.
https://developer.mozilla.org/en-US/docs/Tools/Debugger
https://developer.mozilla.org/en-US/docs/Tools/Debugger/How_to/Step_through_code
I have a pretty patchy history with debuggers myself.
Sometimes I get the program to launch and get to
analyze some code. And sometimes I don't even get out
of the gate. When the code body is large enough (millions
of line), then single stepping is largely a waste of time.
For your little test program, you should see it "step
around" a chunk of your code.
Even if the environment prints "line numbers" on the screen,
this can be a subtle hint you're missing a line termination
character.
********
I wonder if your document.write is correct ?
https://developer.mozilla.org/en-US/docs/Web/API/Document/write
Also, line 15 is missing a semicolon on the end, before the comment.
How did I figure that out ? I took the stuff between
the <script> tags and fed it to this.
http://beautifytools.com/javascript-validator.php
Paul
[toc] | [prev] | [next] | [standalone]
| From | Robert Baer <robertbaer@localnet.com> |
|---|---|
| Date | 2018-01-07 16:24 -0800 |
| Message-ID | <PSy4C.110477$EO4.2575@fx28.iad> |
| In reply to | #10650 |
Paul wrote: > Robert Baer wrote: >> Paul wrote: >>> The other is: how in the heck does one get an "if" to work (that >>> second document.write() does not execute when that if exists). >> OOPS; forgot to ask the above question WRT same program (attached). >> > > I don't see anything wrong with your code. > > It looks to me like it should have executed > both document.write statements. > > And the thing is, you can only do so much by adding > print statements to a program, before you need help. > > ******* > > You can use a debugger. Good luck with this. > > https://developer.mozilla.org/en-US/docs/Tools/Debugger > > https://developer.mozilla.org/en-US/docs/Tools/Debugger/How_to/Step_through_code > > > I have a pretty patchy history with debuggers myself. > Sometimes I get the program to launch and get to > analyze some code. And sometimes I don't even get out > of the gate. When the code body is large enough (millions > of line), then single stepping is largely a waste of time. > For your little test program, you should see it "step > around" a chunk of your code. > > Even if the environment prints "line numbers" on the screen, > this can be a subtle hint you're missing a line termination > character. > > ******** > > I wonder if your document.write is correct ? > > https://developer.mozilla.org/en-US/docs/Web/API/Document/write > > Also, line 15 is missing a semicolon on the end, before the comment. > > How did I figure that out ? I took the stuff between > the <script> tags and fed it to this. > > http://beautifytools.com/javascript-validator.php > > Paul With that help, and some fiddling i got all of my program to work. Now all i have to do is add user I/O AKA read and write to screen. Thanks.
[toc] | [prev] | [next] | [standalone]
| From | Robert Baer <robertbaer@localnet.com> |
|---|---|
| Date | 2018-01-09 22:23 -0800 |
| Message-ID | <zji5C.226670$qV5.119545@fx37.iad> |
| In reply to | #10650 |
Paul wrote:
> Robert Baer wrote:
>> Paul wrote:
>>> The other is: how in the heck does one get an "if" to work (that
>>> second document.write() does not execute when that if exists).
>> OOPS; forgot to ask the above question WRT same program (attached).
>>
>
> I don't see anything wrong with your code.
>
> It looks to me like it should have executed
> both document.write statements.
>
> And the thing is, you can only do so much by adding
> print statements to a program, before you need help.
>
> *******
>
> You can use a debugger. Good luck with this.
>
> https://developer.mozilla.org/en-US/docs/Tools/Debugger
>
> https://developer.mozilla.org/en-US/docs/Tools/Debugger/How_to/Step_through_code
>
>
> I have a pretty patchy history with debuggers myself.
> Sometimes I get the program to launch and get to
> analyze some code. And sometimes I don't even get out
> of the gate. When the code body is large enough (millions
> of line), then single stepping is largely a waste of time.
> For your little test program, you should see it "step
> around" a chunk of your code.
>
> Even if the environment prints "line numbers" on the screen,
> this can be a subtle hint you're missing a line termination
> character.
>
> ********
>
> I wonder if your document.write is correct ?
>
> https://developer.mozilla.org/en-US/docs/Web/API/Document/write
>
> Also, line 15 is missing a semicolon on the end, before the comment.
>
> How did I figure that out ? I took the stuff between
> the <script> tags and fed it to this.
>
> http://beautifytools.com/javascript-validator.php
>
> Paul
Some of this helped.
Validators are not so good; they say given code is OK even when (most
especially when) the code does not work.
The following s a snippet of attempts to (in my words) export a value
from javascript to the HTML page:
// added as attempt to get value to user
document.write( "Error voltage is:" + errVolt ); //at top left
// document.getElementById("dv") = desiredVoltage; //nogo
// document.getElementById("dv").value = desiredVoltage; //nogo
// document.getElementById("dv").innerHTML = desiredVoltage; //nogo
// document.getElementById("dv").id = desiredVoltage; //nogo
// document.getElementById("dv").name = desiredVoltage; //nogo
// document.getElementById("dv").style = desiredVoltage; //nogo
// document.getElementById("dv").text = desiredVoltage; //nogo
// document.getElementById("dv").header = desiredVoltage; //nogo
// document.getElementById("dv").all = desiredVoltage; //nogo
// document.getElementById("dv").select = desiredVoltage; //nogo
var el = document.getElementById('dv');
alert(el.name); // nogo
</SCRIPT>
<div style="position: absolute; top: 30px; left: 550px; " >
<H1 id="dv">Have it here</H1>
</div>
**
As you can see,i have yet to find a variant of
document.getElementById() that will work for this.
Elsewhere, after noodling around like this,i was able to find a
variant that over-wrote a placed image with a different one.
But that variant's form (included in list above) did not work for this.
[toc] | [prev] | [next] | [standalone]
| From | Paul <nospam@needed.invalid> |
|---|---|
| Date | 2018-01-10 03:44 -0500 |
| Message-ID | <p34jph$mq3$1@dont-email.me> |
| In reply to | #10655 |
Robert Baer wrote:
> Paul wrote:
>> Robert Baer wrote:
>>> Paul wrote:
>>>> The other is: how in the heck does one get an "if" to work (that
>>>> second document.write() does not execute when that if exists).
>>> OOPS; forgot to ask the above question WRT same program (attached).
>>>
>>
>> I don't see anything wrong with your code.
>>
>> It looks to me like it should have executed
>> both document.write statements.
>>
>> And the thing is, you can only do so much by adding
>> print statements to a program, before you need help.
>>
>> *******
>>
>> You can use a debugger. Good luck with this.
>>
>> https://developer.mozilla.org/en-US/docs/Tools/Debugger
>>
>> https://developer.mozilla.org/en-US/docs/Tools/Debugger/How_to/Step_through_code
>>
>>
>>
>> I have a pretty patchy history with debuggers myself.
>> Sometimes I get the program to launch and get to
>> analyze some code. And sometimes I don't even get out
>> of the gate. When the code body is large enough (millions
>> of line), then single stepping is largely a waste of time.
>> For your little test program, you should see it "step
>> around" a chunk of your code.
>>
>> Even if the environment prints "line numbers" on the screen,
>> this can be a subtle hint you're missing a line termination
>> character.
>>
>> ********
>>
>> I wonder if your document.write is correct ?
>>
>> https://developer.mozilla.org/en-US/docs/Web/API/Document/write
>>
>> Also, line 15 is missing a semicolon on the end, before the comment.
>>
>> How did I figure that out ? I took the stuff between
>> the <script> tags and fed it to this.
>>
>> http://beautifytools.com/javascript-validator.php
>>
>> Paul
> Some of this helped.
> Validators are not so good; they say given code is OK even when (most
> especially when) the code does not work.
>
> The following s a snippet of attempts to (in my words) export a value
> from javascript to the HTML page:
> // added as attempt to get value to user
> document.write( "Error voltage is:" + errVolt ); //at top left
>
> // document.getElementById("dv") = desiredVoltage; //nogo
> // document.getElementById("dv").value = desiredVoltage; //nogo
> // document.getElementById("dv").innerHTML = desiredVoltage; //nogo
> // document.getElementById("dv").id = desiredVoltage; //nogo
> // document.getElementById("dv").name = desiredVoltage; //nogo
> // document.getElementById("dv").style = desiredVoltage; //nogo
> // document.getElementById("dv").text = desiredVoltage; //nogo
> // document.getElementById("dv").header = desiredVoltage; //nogo
> // document.getElementById("dv").all = desiredVoltage; //nogo
> // document.getElementById("dv").select = desiredVoltage; //nogo
>
> var el = document.getElementById('dv');
> alert(el.name); // nogo
> </SCRIPT>
>
> <div style="position: absolute; top: 30px; left: 550px; " >
> <H1 id="dv">Have it here</H1>
> </div>
>
> **
> As you can see,i have yet to find a variant of
> document.getElementById() that will work for this.
>
> Elsewhere, after noodling around like this,i was able to find a
> variant that over-wrote a placed image with a different one.
> But that variant's form (included in list above) did not work for this.
It's funny that one site makes it look like getElementById is details-free.
But this page, talks about "global scope" and demonstrate it working
by fetching an object from the HTML portion of the page, for
usage inside the Javascript portion. Is this how you're using it ?
https://developer.mozilla.org/en-US/docs/Web/API/Document/getElementById
HTML Content
<html>
<head>
<title>getElementById example</title>
</head>
<body>
<p id="para">Some text here</p>
<button onclick="changeColor('blue');">blue</button>
<button onclick="changeColor('red');">red</button>
</body>
</html>
JavaScript Content
function changeColor(newColor) {
var elem = document.getElementById('para');
elem.style.color = newColor;
}
*******
HTH,
Paul
[toc] | [prev] | [next] | [standalone]
| From | Paul <nospam@needed.invalid> |
|---|---|
| Date | 2018-01-10 22:44 -0500 |
| Message-ID | <p36mj8$nft$1@dont-email.me> |
| In reply to | #10656 |
Robert Baer wrote:
> OK; tried your program and modified it to be as close as possible to
> my non-functional program and it still works; try attached.
>
> The only good thing is that i have _something_ working.....
> Guess i will have to radically pare down my program even more to find
> WTH is happening to kill the data transfer.
>
> Thanks,
> R. Baer
Tools : Web Development : Error Console <=== is your friend
I just tried it.
Now, I've been fiddling with this for at least an hour,
and couldn't get anything to change. Then, suddenly...
******************************************************
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
</head>
<body>
<p id="xy">This is stupid.</p>
<p id="demo">This sentence does NOT get replaced like in W3C demo AND document.write() fails.</p>
<script>
var test1 = document.getElementById('demo');
test1.innerHTML;
document.write(3+4,"<br><br>");
</script>
Reference: https://www.w3schools.com/js/tryit.asp?filename=tryjs_output_dom
</body>
</html>
******************************************************
The declaration in the head, is solely to stop an error from
showing in the Error Console. It has nothing to do with the function
of your script.
I didn't think making a variable called "test1" would help,
but figured what the hell - maybe it doesn't reference an element
from a returned function result or something.
Now, just putting innerHTML like that, with the semicolon, I
understood that to assign "null" or nothing to it.
And then suddenly the number "7" starts appearing on my screen.
So I tidied it up so it would look pretty for a demo, by putting
a couple blank lines after it.
Notice that "demo" is still not getting overwritten. But content
is being added after it, for some reason.
Anyway, this is the first positive result I've had, after trying
stuff.
And the error console helps... a little bit.
Paul
[toc] | [prev] | [next] | [standalone]
| From | Paul <nospam@needed.invalid> |
|---|---|
| Date | 2018-01-12 02:49 -0500 |
| Message-ID | <p39pab$ijv$1@dont-email.me> |
| In reply to | #10657 |
Robert Baer wrote:
> Paul wrote:
>> Robert Baer wrote:
>>
>>> OK; tried your program and modified it to be as close as possible to
>>> my non-functional program and it still works; try attached.
>>>
>>> The only good thing is that i have _something_ working.....
>>> Guess i will have to radically pare down my program even more to
>>> find WTH is happening to kill the data transfer.
>>>
>>> Thanks,
>>> R. Baer
>>
>> Tools : Web Development : Error Console <=== is your friend
>>
>> I just tried it.
>>
>> Now, I've been fiddling with this for at least an hour,
>> and couldn't get anything to change. Then, suddenly...
>>
>> ******************************************************
>> <!DOCTYPE html>
>> <html>
>> <head>
>> <meta http-equiv="Content-Type" content="text/html;
>> charset=ISO-8859-1">
>> </head>
>>
>> <body>
>> <p id="xy">This is stupid.</p>
>> <p id="demo">This sentence does NOT get replaced like in W3C demo AND
>> document.write() fails.</p>
>> <script>
>> var test1 = document.getElementById('demo');
>> test1.innerHTML;
>> document.write(3+4,"<br><br>");
>> </script>
>> Reference:
>> https://www.w3schools.com/js/tryit.asp?filename=tryjs_output_dom
>> </body>
>> </html>
>> ******************************************************
>>
>> The declaration in the head, is solely to stop an error from
>> showing in the Error Console. It has nothing to do with the function
>> of your script.
>>
>> I didn't think making a variable called "test1" would help,
>> but figured what the hell - maybe it doesn't reference an element
>> from a returned function result or something.
>>
>> Now, just putting innerHTML like that, with the semicolon, I
>> understood that to assign "null" or nothing to it.
>>
>> And then suddenly the number "7" starts appearing on my screen.
>> So I tidied it up so it would look pretty for a demo, by putting
>> a couple blank lines after it.
>>
>> Notice that "demo" is still not getting overwritten. But content
>> is being added after it, for some reason.
>>
>> Anyway, this is the first positive result I've had, after trying
>> stuff.
>>
>> And the error console helps... a little bit.
>>
>> Paul
> Thanks.
> FYI, i can not get any "error console" or "debug" or any other
> supposed tracing to work...not even InternetExploder (you can see i was
> getting desperate).
>
> Posted the question in StackOverflow and got what looks like very
> useful answers.
>
> Posting with comments/answers included attached.
>
> I think with this info, i can make (almost?) all of it work.
> At least the data output part problem looks fixable.
>
> Data input (to the javascript code) is something else...
>
> Thanks.
>
Using the old FOO I can show an example.
In Seamonkey
Tools : Web Development : Error Console
In Firefox
Tools : Web Developer : Web Console
https://s13.postimg.org/7yfcpj9rr/console.gif
Back later.
HTH,
Paul
[toc] | [prev] | [next] | [standalone]
| From | Robert Baer <robertbaer@localnet.com> |
|---|---|
| Date | 2018-01-12 21:10 -0800 |
| Message-ID | <hxg6C.101330$b67.65217@fx20.iad> |
| In reply to | #10658 |
Paul wrote:
> Robert Baer wrote:
>> Paul wrote:
>>> Robert Baer wrote:
>>>
>>>> OK; tried your program and modified it to be as close as possible to
>>>> my non-functional program and it still works; try attached.
>>>>
>>>> The only good thing is that i have _something_ working.....
>>>> Guess i will have to radically pare down my program even more to
>>>> find WTH is happening to kill the data transfer.
>>>>
>>>> Thanks,
>>>> R. Baer
>>>
>>> Tools : Web Development : Error Console <=== is your friend
>>>
>>> I just tried it.
>>>
>>> Now, I've been fiddling with this for at least an hour,
>>> and couldn't get anything to change. Then, suddenly...
>>>
>>> ******************************************************
>>> <!DOCTYPE html>
>>> <html>
>>> <head>
>>> <meta http-equiv="Content-Type" content="text/html;
>>> charset=ISO-8859-1">
>>> </head>
>>>
>>> <body>
>>> <p id="xy">This is stupid.</p>
>>> <p id="demo">This sentence does NOT get replaced like in W3C demo AND
>>> document.write() fails.</p>
>>> <script>
>>> var test1 = document.getElementById('demo');
>>> test1.innerHTML;
>>> document.write(3+4,"<br><br>");
>>> </script>
>>> Reference:
>>> https://www.w3schools.com/js/tryit.asp?filename=tryjs_output_dom
>>> </body>
>>> </html>
>>> ******************************************************
>>>
>>> The declaration in the head, is solely to stop an error from
>>> showing in the Error Console. It has nothing to do with the function
>>> of your script.
>>>
>>> I didn't think making a variable called "test1" would help,
>>> but figured what the hell - maybe it doesn't reference an element
>>> from a returned function result or something.
>>>
>>> Now, just putting innerHTML like that, with the semicolon, I
>>> understood that to assign "null" or nothing to it.
>>>
>>> And then suddenly the number "7" starts appearing on my screen.
>>> So I tidied it up so it would look pretty for a demo, by putting
>>> a couple blank lines after it.
>>>
>>> Notice that "demo" is still not getting overwritten. But content
>>> is being added after it, for some reason.
>>>
>>> Anyway, this is the first positive result I've had, after trying
>>> stuff.
>>>
>>> And the error console helps... a little bit.
>>>
>>> Paul
>> Thanks.
>> FYI, i can not get any "error console" or "debug" or any other
>> supposed tracing to work...not even InternetExploder (you can see i
>> was getting desperate).
>>
>> Posted the question in StackOverflow and got what looks like very
>> useful answers.
>>
>> Posting with comments/answers included attached.
>>
>> I think with this info, i can make (almost?) all of it work.
>> At least the data output part problem looks fixable.
>>
>> Data input (to the javascript code) is something else...
>>
>> Thanks.
>>
>
> Using the old FOO I can show an example.
>
> In Seamonkey
>
> Tools : Web Development : Error Console
>
> In Firefox
>
> Tools : Web Developer : Web Console
>
> https://s13.postimg.org/7yfcpj9rr/console.gif
>
> Back later.
>
> HTH,
> Paul
At least your error console no only hows,but it seems to do something.
Just meaningless words here.
What version of FF?
[toc] | [prev] | [next] | [standalone]
| From | Paul <nospam@needed.invalid> |
|---|---|
| Date | 2018-01-12 03:00 -0500 |
| Message-ID | <p39pv3$lc0$1@dont-email.me> |
| In reply to | #10657 |
Robert Baer wrote:
<programming problem>
Quickest change I could do, was to move
your script section inside the div. Hope
this pushed you along a tiny bit further.
****************************************************
<!DOCTYPE HTML>
<html lang="en">
<head>
<title>Test of document.getElementById(id)</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<!-- Copied from https://www.w3schools.com/js/js_output.asp "Using innerHTML" -->
<h1>My First Web Page</h1>
<p>My First Paragraph</p>
<p id="demo"></p>
<script>
document.getElementById("demo").innerHTML = 5 + 6;
</script>
<br> Above works, so go for the gold. <br>
<p id="first">Some text here. This works</p>
<div style="position: absolute; top: 30px; left: 550px; ">
<p> For Codatron® PCB programming. </p>
<H1 id="dv">Have it here</H1>
<script>
var fullUNPOP = 1290; // Full, unpopulated board voltage
var unitVoltage = fullUNPOP / 78;
var desiredVoltage = 1250; // ** TEST FOR ALL JUMPERS REMOVED
// attempt to get value to user
document.write("Unit voltage is:" + unitVoltage + "<br>"); //at top left
document.write("Desired voltage is:" + desiredVoltage + "<br>"); //near top left
document.getElementById('dv').innerHTML = fullUNPOP; // "Have it here" gets replaced with voltage
//document.getElementById('ev').innerHTML = unitVoltage;
</script>
</div>
<script>
var fullUNPOP = 1290; // Full, unpopulated board voltage
var unitVoltage = fullUNPOP / 78;
var desiredVoltage = 1250; // ** TEST FOR ALL JUMPERS REMOVED
// attempt to get value to user
document.write("Unit voltage is:" + unitVoltage + "<br>"); //at top left
document.write("Desired voltage is:" + desiredVoltage + "<br>"); //near top left
document.getElementById('dv').innerHTML = fullUNPOP; // "Have it here" gets replaced with voltage
document.getElementById('ev').innerHTML = unitVoltage; // "Reference: Paul" DOES NOT get replaced
</script>
<p id="ev">Reference: Paul</p>
NOTE: above did NOT work
</body>
</html>
****************************************************
Paul
[toc] | [prev] | [next] | [standalone]
| From | Robert Baer <robertbaer@localnet.com> |
|---|---|
| Date | 2018-01-12 21:16 -0800 |
| Message-ID | <rCg6C.355007$iX.314411@fx39.iad> |
| In reply to | #10659 |
Paul wrote:
> Robert Baer wrote:
>
> <programming problem>
>
> Quickest change I could do, was to move
> your script section inside the div. Hope
> this pushed you along a tiny bit further.
>
> ****************************************************
> <!DOCTYPE HTML>
> <html lang="en">
>
> <head>
> <title>Test of document.getElementById(id)</title>
> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
> </head>
>
> <body>
> <!-- Copied from https://www.w3schools.com/js/js_output.asp "Using
> innerHTML" -->
> <h1>My First Web Page</h1>
> <p>My First Paragraph</p>
>
> <p id="demo"></p>
>
> <script>
> document.getElementById("demo").innerHTML = 5 + 6;
> </script>
>
> <br> Above works, so go for the gold. <br>
>
> <p id="first">Some text here. This works</p>
> <div style="position: absolute; top: 30px; left: 550px; ">
> <p> For Codatron® PCB programming. </p>
> <H1 id="dv">Have it here</H1>
> <script>
> var fullUNPOP = 1290; // Full, unpopulated board voltage
> var unitVoltage = fullUNPOP / 78;
> var desiredVoltage = 1250; // ** TEST FOR ALL JUMPERS REMOVED
> // attempt to get value to user
> document.write("Unit voltage is:" + unitVoltage + "<br>");
> //at top left
> document.write("Desired voltage is:" + desiredVoltage +
> "<br>"); //near top left
> document.getElementById('dv').innerHTML = fullUNPOP; //
> "Have it here" gets replaced with voltage
> //document.getElementById('ev').innerHTML = unitVoltage;
> </script>
> </div>
> <script>
> var fullUNPOP = 1290; // Full, unpopulated board voltage
> var unitVoltage = fullUNPOP / 78;
> var desiredVoltage = 1250; // ** TEST FOR ALL JUMPERS REMOVED
> // attempt to get value to user
> document.write("Unit voltage is:" + unitVoltage + "<br>"); //at
> top left
> document.write("Desired voltage is:" + desiredVoltage +
> "<br>"); //near top left
> document.getElementById('dv').innerHTML = fullUNPOP; // "Have
> it here" gets replaced with voltage
> document.getElementById('ev').innerHTML = unitVoltage; //
> "Reference: Paul" DOES NOT get replaced
> </script>
> <p id="ev">Reference: Paul</p>
> NOTE: above did NOT work
>
> </body>
>
> </html>
> ****************************************************
>
> Paul
Check; then move those last 2 lines now after </script> to before
<script>.
Magic.
And i thought that innerHTML was supposed to look everywhere in the
HTML document...
[toc] | [prev] | [next] | [standalone]
| From | Paul <nospam@needed.invalid> |
|---|---|
| Date | 2018-01-12 04:29 -0500 |
| Message-ID | <p39v6l$loh$1@dont-email.me> |
| In reply to | #10657 |
Robert Baer wrote:
> Thanks.
> FYI, i can not get any "error console" or "debug" or any other
> supposed tracing to work...not even InternetExploder (you can see i was
> getting desperate).
>
> Posted the question in StackOverflow and got what looks like very
> useful answers.
>
> Posting with comments/answers included attached.
>
> I think with this info, i can make (almost?) all of it work.
> At least the data output part problem looks fixable.
>
> Data input (to the javascript code) is something else...
>
> Thanks.
We really need some articles on "scoping", and even this
isn't enough to please me.
https://www.w3schools.com/js/js_scope.asp
This one is the opposite extreme, and doesn't even touch HTML.
https://toddmotto.com/everything-you-wanted-to-know-about-javascript-scope/
You can put your Javascript in a separate file.
<html>
<head>
<script type=text/javascript src=test.js></script>
</head>
<body onload="alert(test);"> </body>
</html>
Where test.js contains:
var test = 'hello!';
*******
And you can see in one of the examples here, the namespace
example, the language is a lot more complicated than that.
https://stackoverflow.com/questions/751882/html-javascript-include-file-variable-scope
var MyNamespace = (function () {
var myVar = "something";
return { alert: function() { alert(myVar) },
setVar: function(value) { myVar = value } }
})();
That would be an "I'm sorry I asked" example.
Paul
[toc] | [prev] | [next] | [standalone]
| From | Robert Baer <robertbaer@localnet.com> |
|---|---|
| Date | 2018-01-12 21:39 -0800 |
| Message-ID | <dYg6C.320263$zw5.83587@fx17.iad> |
| In reply to | #10660 |
Paul wrote:
> Robert Baer wrote:
>
>> Thanks.
>> FYI, i can not get any "error console" or "debug" or any other
>> supposed tracing to work...not even InternetExploder (you can see i
>> was getting desperate).
>>
>> Posted the question in StackOverflow and got what looks like very
>> useful answers.
>>
>> Posting with comments/answers included attached.
>>
>> I think with this info, i can make (almost?) all of it work.
>> At least the data output part problem looks fixable.
>>
>> Data input (to the javascript code) is something else...
>>
>> Thanks.
>
> We really need some articles on "scoping", and even this
> isn't enough to please me.
>
> https://www.w3schools.com/js/js_scope.asp
>
> This one is the opposite extreme, and doesn't even touch HTML.
>
> https://toddmotto.com/everything-you-wanted-to-know-about-javascript-scope/
* BUT their first "example" is flawed; i hate "examples because most do
not work or are flawed like this one:
*QUOTE*
Before you write a line of JavaScript, you’re in what we call the Global
Scope. If we declare a variable, it’s defined globally:
// global scope
var name = 'Todd';
*UNQUOTE*
It is wrong and flawed because it is not eXplicitly stated that one
MUST BE USING JAVASCRIPT.
In fact, it is very bad in that it states "Before...".
Just try the line "var name = 'Todd';" in the HTML section and see
how the W3C checker goes wild...
>
> You can put your Javascript in a separate file.
* Yes; that is very common and a number of useful code files are
publically available to help preventing the making of the wheel but also
to have the most correct wheel available.
For example, a snippet from a working, W3C passed file:
<!--[if lt IE 8]>
<script src="https://code.google.com/p/html5shiv" ></script>
<script src="https://github.com/scottjehl/Respond"></script>
<![endif]-->
<script
src="https://cdnjs.cloudflare.com/ajax/libs/modernizr/2.7.1/modernizr.min.js"
></script>
<script src="js/css3-mediaqueries.js" ></script>
<script src="js/jquery.js"></script>
<script src="js/bootstrap.min.js" ></script>
>
> <html>
> <head>
> <script type=text/javascript src=test.js></script>
> </head>
>
> <body onload="alert(test);"> </body>
>
> </html>
>
> Where test.js contains:
>
> var test = 'hello!';
>
> *******
>
> And you can see in one of the examples here, the namespace
> example, the language is a lot more complicated than that.
>
> https://stackoverflow.com/questions/751882/html-javascript-include-file-variable-scope
>
>
> var MyNamespace = (function () {
> var myVar = "something";
> return { alert: function() { alert(myVar) },
> setVar: function(value) { myVar = value } }
> })();
>
> That would be an "I'm sorry I asked" example.
>
> Paul
Do not understand that at all. Suffice to say i ain't gonna ask..
[toc] | [prev] | [standalone]
Back to top | Article view | alt.computer
csiph-web