Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > alt.computer > #10656

Re: javascript help, please

From Paul <nospam@needed.invalid>
Newsgroups alt.computer
Subject Re: javascript help, please
Date 2018-01-10 03:44 -0500
Organization A noiseless patient Spider
Message-ID <p34jph$mq3$1@dont-email.me> (permalink)
References <kRy2C.27980$b_.4386@fx23.iad> <p2fj8s$1k7$1@dont-email.me> <ElT2C.170585$iX.1455@fx39.iad> <p2h3vh$u2p$1@dont-email.me> <zji5C.226670$qV5.119545@fx37.iad>

Show all headers | View raw


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

Back to alt.computer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

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

csiph-web