Some Insight Into The Document Object Model: How Forms Are Stored By JavaScript

Recently asked on Yahoo! Answers:

JavaScript Submit form?

Ok, I know of the function…

function submitform() {document.myform.submit();}

however, for this to work, I have to name my forms, also, if I want to use it multiple times on the same page, each funtion name must be unique.

Is there a way to replace a submit button with javascript without having to uniquely name each function, or name my forms? I’m just looking for a link replacement for the submit button. So, a submit button just sits at the end of the form and submits it’s data, can I just replace it with a link, no extra stuff except one function at the top of the screen?

Also, the form’s method is POST, not GET. Also, the action is $PHP_SELF; though, if you give me an ideal answer, the JavaScript won’t even worry about the action.

This is something I don’t see as often as I’d like: A question about how something works, and a question with a practical application.

In other words, the user wants to solve a particular problem, but the question is posed in a way that its answer can reveal a great deal about how the Document Object Model (DOM) works. And understanding how things work makes programming far easier, believe me.

I began answering the direct question of how to submit an unnamed form with JavaScript, but then decided that, because opportunities like this are so rare, I’d seize upon it and launch a full dissertation here.

Before we begin, I’m going to be tossing around some terms about how classes / objects work. If you’re new to programming, or at least object-oriented programming, and aren’t familiar with terms such as “property,” “method,” “event” or “namespace,” you’ll want to check out my earlier entry, titled “Objects (Classes) Explained In Very Simple Terms.”

Read the rest of this entry »

Good, Free Web Site Building Tools

A common question on Yahoo! Answers is how to go about making a Web site.

Generally speaking, people asking that question are best off using templates provided by Web hosts such as Freewebs, Geocities, WordPress or Blogger; these systems take out the guesswork and make otherwise complicated design tasks relatively easy.

But sometimes, the questioner is really asking where to find good, free Web site building tools. Fortunately, there are still lots of free tools available out there, many every bit as good as software costing hundreds of dollars a copy.

Read the rest of this entry »

Fixing An “Unterminated String Literal” Error In An AJAX JavaScript HttpRequest

So you’ve written your first AJAX program, tested it, and it seems to work. Except sometimes, when your “helper script” is supposed to return some data from your database, you get this error:

Unterminated string literal

What gives? Basically, you’ve run into a quote mark in your data — and because it doesn’t know any better, JavaScript thinks you mean for it to end a string.

Of course, that’s not what you meant. As a result, you have more text appearing after what JavaScript considers the end of a string.

And when JavaScript sees that extra text, it wants it to start and end with quotes. Since, as far as JavaScript is concerned, that extra text isn’t fully enclosed in quotes, it’s unterminated — thus, an “unterminated string literal.”

Let’s look at this more closely, and see how simple it is to clear up.

Read the rest of this entry »

How I Maintain A High “Best Answers” Percentage On Yahoo! Answers

Asked recently in an e-mail message:

Hi Doug,

I was just wondering since my ratio is a lot less due to abandoned questions

Do you have some kind of special method you want to share to get the best answer like only answering the very difficult questions with such a complete answer that they just have to give it a best answer?

Thanks

Michel (newb on Yahoo, veteran on other sites)

This is actually a fairly common question. My Best Answers percentage hovers around 80 percent and has pretty much throughout my participation in Answers. Since the average Level 7 user of Yahoo! Answers has a Best Answers percentage of around 50 percent, my total seems quite high.

However, as Michel notes, circumstances can make your Best Answers percentage much higher — and, not coincidentally, your Answers experience a lot more enjoyable.

Read the rest of this entry »

eBay Vendor Review: dom341

Vendor Name: dom341
Item Purchased: AIR ASSAULT ON CRETE (160242430149)

Item As Described: Yes
Shipped Quickly: No
Customer Service: N/A

I won this game on the Saturday of Memorial Day weekend, so I knew I wouldn’t get it quickly. But this seller didn’t even put it in the mail until May 30. To me, that’s unacceptable: Ship the item as soon as you are paid.

(And no, the fact that it’s a holiday weekend shouldn’t have an impact on shipping expectations. I don’t buy if I can’t pay immediately; people shouldn’t sell if they can’t ship immediately. If a seller wants to take a week off, fine; he should suspend his auctions or set them to end when he’s ready to fulfill his orders. It’s that simple.)

Even so, this was a fine purchase, described fairly (as much as it was described) and I got it for a good price. I might well use this vendor again, but I would need better assurances about shipping time.