
Ask HN for help - JavaScript newbie with a problem. - ColinWright
http://www.solipsys.co.uk/HelpMyJavaScript.html
======
jcr
hiya Colin. It's been a while. Anyhow, the problem is in the 'type' of your
script element:

    
    
      - <script type="javascript">
      + <script type="text/javascript">

~~~
ColinWright
Hiya - yes, and I owe you an email, I'm getting to it.

Anyway, file changed, but that doesn't seem to have fixed it. Any other
suggestions?

~~~
thaumaturgy
jcr was partly right -- that change does need to be made -- but you also have
to change the way that you reference the form element. You're using a very old
(Netscape 4.0-era I think) way of referencing form elements in the DOM that
apparently isn't supported anymore.

Add an id="results" attribute to the text box, then change the line in your
display() function to this:

    
    
        document.getElementById('results').value = "test"
    

That works for me.

~~~
ColinWright
That looks like it works for me to - will upload now ...

Edit: Works on the server too. Thanks.

Any idea when this changed, and how I could've searched for this? Suppose
someone took a JavaScript course back in pre-Netscape 4.0 - how would they
come up-to-date?

As an algorithms person I find it completely baffling trying to learn, search,
and investigate this stuff. It feels completely impenetrable. I have a PhD in
Pure Math, and this makes me feel really thick.

~~~
thaumaturgy
I'm not honestly sure when support for it was dropped; I know it fell out of
favor at least 7 or 8 years ago. I can't quickly find a reference on the web
to when support for legacy DOM was dropped, either.

For me, the third result for "javascript element value" is
[http://stackoverflow.com/questions/1988614/how-to-get-
hidden...](http://stackoverflow.com/questions/1988614/how-to-get-hidden-
element-value-in-javascript); the top result is a post full of techniques that
work, but aren't what I'd use.

How you'd get up to date depends a little on how far you want to go with
Javascript. If you just want to be able to do basic stuff and then get on with
your work, probably your best bet is to use jQuery and start with their
tutorials (<http://docs.jquery.com/Tutorials:Getting_Started_with_jQuery>).
jQuery does a nice job of abstracting away many of the annoying things about
the DOM and the various browser quirks associated with it.

If you wanted to really delve in to Javascript, I'm not really sure what to
recommend. You would be throwing out most of the Netscape 4.0 way of doing
things, and you'd eventually want to learn things like closures and
Javascript's occasionally-annoying "everything is a global variable by
default" and so on. One of the revered volumes would probably be best I guess:
[http://stackoverflow.com/questions/74884/good-javascript-
boo...](http://stackoverflow.com/questions/74884/good-javascript-books)

I hear you on your frustration with it. Getting used to using the web
inspector in Chrome or Firebug in Firefox helps, but error messages can be
unhelpful, and you can find yourself swimming through lots of outdated (or
incorrect, or even just "that's not how most people do things") blog posts
when looking for answers. It's not quite like the good ol' days where you
could drop in to a debugger and see the entire environment state and step
through your code and so on. The mix of html and css and javascript also makes
for this horrifically broad field of knowledge, most of which isn't really
derivative, so it becomes a matter of trial-and-error and memorization.

~~~
ColinWright
That's a really, _really_ useful reply. Thank you.

------
oliakaoil
I don't get it. Why is this on HN?

~~~
ColinWright
Because not every hacker is a web developer. I, for example, am a self-
confessed non-web developer. I program big iron and embedded systems in a
safety critical context. I'm not scraping database for information and
arranging it on the screen nicely for people to make purchases, I'm helping to
stop oil tankers from crashing into nuclear submarines.

But occasionally I, and others, stray from our core competencies and either
choose to or have to deal with things with which they are unfamiliar. In those
cases it's nice to have a community to turn to consisting of people who _do_
have expertise and experience in the unfamiliar area.

If it's not too often, and if it's obvious that people have made a genuine
attempt to sort things out for themselves, and if the question is distilled to
its essence, it's possible that more than one person can learn from the
resulting thread.

And many times I've answered people's questions about math, or algorithms, and
it's nice to get something back. So thank you to those who replied - it's
pretty much sorted now, and I've learned something.

~~~
oliakaoil
If you spend your days preventing the next global ecological or thermonuclear
disaster and looking down your nose at those who do something like sell a
product, I find it hard to believe that you have a hard time figuring out
something like this without reaching out to the community in this manner, but
that is another issue I'm not interested in. What I was asking about is the
fact that I have been reading HN for about a year now and I've never seen a
"story" like this come into my news feed. I was wondering why one suddenly
popped.

~~~
ColinWright
I don't look down my nose at people "who do something like sell a product" - I
have great respect for their skills, and for what they do. I, too, sell
products and provide services, I just do it in a different context, albeit
still computer based. Business-wise the activities have a lot in common. I'm
trying to point out that the skills required in scraping databases and
arranging things on screens is not what I do, and I find it hard. If nothing
else it's an acknowledgement that people who do web development are skills I
don't have.

    
    
        I find it hard to believe that you have a hard time
        figuring out something like this without reaching out
        to the community in this manner.
    

And I have a hard time believing that people struggle with some of the
elementary math I see questions about, but I generally assume that they have
other skills, and that this stuff is hard for them, so that's why I do what I
can to help when I get the opportunity. Different people have different
skills, different training, different experience and different talents.

    
    
        What I was asking about is the fact that I have been
        reading HN for about a year now and I've never seen
        a "story" like this come into my news feed. I was
        wondering why one suddenly popped.
    

Well, I've been reading HN for about 5 years now, and I've seen them before.
Not often, and usually they are fleeting because the answers come quickly and
efficiently, so the item never makes it to the Front Page. It doesn't have to.

