Archive for the 'Yahoo! Answers' Category

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 »

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 »

Answers User, Want To Contact Me? Please Read This First

Many people contact me directly with questions. I’m very flattered and very appreciative when that happens.

To ensure that I give you an answer you find useful, and everyone can share in that effort, I make the following requests.

Please post your question to Answers first, then e-mail me the question. That way, everyone can see the answer. Besides, I’m not the only person answering questions. If you post your question, you may well get a faster, or better, answer.

Once your question is posted, you’ll notice it has a little envelope icon right beneath your text. Simply click on that and follow the instructions to send the question to dhvrm@yahoo.com.

Please add your e-mail address in the Message field. Answers uses its own e-mail address to send questions, not yours; so I cannot contact you if you don’t put your e-mail address in the Message field.

Read the rest of this entry »

Editing Text On Click With JavaScript / DOM

Recently asked in Yahoo! Answers:

Clickable text to edit? Javascript?
So I saw somewhere on this website that they had rows of DYNAMIC data that when you clicked on the actual text (onfocus), the text would turn into a editable text field containing the text, and then when you clicked off of it (onblur?), AJAX was used to update the database that the data came from with that new changed value. I believe it was used to edit categories on the fly.

How do I do this? I can figure out the AJAX/PHP/Mysql part, but I really suck at javascript. I just need to be able to have some text turn into a text field when clicked that contains that text for editing. I’m sure you understand.

Thanks so much.

This is actually pretty straightforward. Basically, you do it with two DIVs: one contains the text you want to make editable, the other contains a textarea that will edit the text. Clicking on the text DIV makes the edit DIV visible; submitting the edits changes the text and hides the edit form.

But, like all things that seem simple, there are a couple of small adjustments we need to make to ensure our solution both works as intended and is safe from HTML injection.

Let’s get to it. As always, a working demo / code you can download appears at the end of this entry.

Read the rest of this entry »