************************************************************
Goodies to Go ™
May 9, 2005 — Newsletter # 336
************************************************************
Featured this week:
Hey Man, What’s OOP?
* Q & A Goodies
* News Goodies
* Feedback Goodies
* Windows Tech Goodie of the Week
* And Remember This…
apparently, many others of you don’t. For that reason, I provide this
description of OOP in a nutshell.
days program code was program code and data was data. It provided a nice
clean distinction, but wasnt necessarily the most efficient way of doing
things. For example, if you had a date and time stored somewhere and you
wanted to print them on a report, you would have to write some code to
extract its elements (such as the month or the hour) and format them with
all the special characters, etc. needed to make them look right on the
report.
of data and program code. The program code provides a set of capabilities,
called methods, which work with the data in the object. For example, there
could be a method in the object that formats the date and time to make it
just right for printing. This way, you would only have to refer to the
method of the object to have your data presented to your program just how
you need it.
the object. For example, an object containing a string of character data
would have a "length" property to tell us how long the string of data is.
within the objects.
form element is described in JavaScript. A form element object (a entry
field, for example) is contained within a form object, which is contained
within a document object. Its value can then be referenced in JavaScript as
document.form.element.value.
for writing the same code over and over again.
provide sufficient support for it for some pretty good Object Oriented code
to be written.
– Vince Barnes
***********************************
Questions are taken from submissions to our Community
Mentors. You can ask a Mentor a question by going to
https://www.htmlgoodies.com/mentors/
Q. I currently need funding for publishing my web-page and such. I know
advertising is a great way to earn money. I recently read your article
about sponsors/advertising. I will be able to advertise and such. But i was
wondering how to get a web-page on a search engine. How do I find out and
about how much will it cost?
engines.
You can, for instance send $299 to Yahoo, but they only guarantee to look at
your site. For that money they may not even list your site.
Optimize your site for the search engines correctly and you can then
manually submit them to the search engines. Within all search site you
should be able to see a link "Submit site here" or something like that.
I suggest you take a look at this site for information about correctly
optimizing your site and submitting that to the engines:
http://selfpromotion.com
program like (I use SmartFTP) some others use CuteFTP… both are good.
I was able to create a cgi-bin folder in my main directory on my
webspace…. not sure if it will work unless created via telnet?
you mentioned should be enough to upload files to your web server. I believe
what you are looking for is to be able to set permissions on your folder.
This all depends on what you have set up between you and your web host. You
can create a CGI folder but you may not be able to set the needed
permissions on the folder. For that you need to contact your host.
Q. Can you please tell me how to add variables? I know you are
supposed to
add two variables with a + sign but it doesn’t work most of the time. It
adds the number to the end of the variable instead of adding them together.
For example, if I wrote this:
var a = 7;
var b = 2;
var c = a + b;
document.write( c );
I would get 72. Can you please tell me how to correct this?
enclosed in quotation marks. If a number is enclosed in quotation marks, it
is treated as a string. In JavaScript, the + sign is used for
concatenation, or the combining of strings, as well as the addition of
numbers.
Using your example:
var a = "7";
var b = "2";
var c = a + b;
document.write( c );
will return "72" as a string (without the quotation marks of course), but:
var a = 7;
var b = 2;
var c = a + b;
document.write( c );
will return 9 as a number. So, if your results are concatenations instead of
numbers, check your code and remove any quotation marks from around digits
that should be treated as numbers.
will be treated as a string. Here is the problem. When I have a user enter
a number to be used for math it is treated as a string. Then when I do math
with it the number is added to the end which makes the answer incorrect.
Can you please give me a method for the user to be able to enter a number
and have it treated like a value instead of a string? Or if not, is there a
way to convert strings into values?
The workaround is to use the eval() function when processing that value as a
number. If your user inputs a number to a text area in a form, and that
number is to be added, subtracted, mutiplied, … etc, process the number
within the eval() function. From your previous example, suppose the user
inputs to the variables a and b via text boxes in a form, you can then add a
to b to return c with this:
c = eval(a)+ eval(b)
This way, the values in both a and b will be treated as numbers instead of
strings.
create variables and then when I try to use them I get an error saying that
they are undefined. Why is this? Here is an example of when this happens:
<SCRIPT LANGUAGE="JavaScript">
function part1()
{
var a = 1;
}
function part2()
{
if (a == 1)
{
document.form.textbox.value = "The variable worked, finally!!!";
}
}
</SCRIPT>
</HEAD>
<BODY>
<FORM NAME="form">
<INPUT TYPE="RADIO" NAME="why_doesnt" VALUE="the_variable_work"
onClick="part1();">
<INPUT TYPE="BUTTON" VALUE="Variable work?" onClick="part2();">
<INPUT TYPE="TEXT" NAME="textbox" VALUE="If the variable worked, a message
would appear here.">
</FORM>
If I write this in a document and click the button, an error message comes
up saying that it is undefined. I’ve tried creating the variable directly
from the event handler, renaming the variable, using checkboxes instead of
radio buttons, and nothing works. I have tried putting an alert box in the
function and it comes up so I know the function is executing. It just won’t
remember the variable.
local variable that is only accessable by that function. You can make it a
global variable that is accessable by any function by declaring it from
outside any functions, but still between the script tags. Usually global
variables are declared before the first function for the sake of clarity,
but they can be declared from anywhere between the script tags, just not
inside a function. Here’s your script with a as a global variable:
<SCRIPT LANGUAGE="JavaScript">
var a = 0; // declares a as a global variable and initializes it to 0
function part1()
{
a = 1; // the function sets the global variable a to equal 1
}
function part2()
{
if (a == 1)
{
document.form.textbox.value = "The variable worked, finally!!!";
}
}
</SCRIPT>
</HEAD>
<BODY>
<FORM NAME="form">
<INPUT TYPE="RADIO" NAME="why_doesnt" VALUE="the_variable_work"
onClick="part1();">
<INPUT TYPE="BUTTON" VALUE="Variable work?" onClick="part2();">
<INPUT TYPE="TEXT" NAME="textbox" VALUE="If the variable worked, a message
would appear here.">
</FORM>
***********************************
[May 9, 2005] The systems vendor will pay $50M cash for Procom’s
network-attached storage software.
Read the article:
http://www.internetnews.com/storage/article.php/3503531
E-Mail Apps Power PDA Shipments
[May 9, 2005] Wireless e-mail drove a 25% increase in handheld shipments
during the first quarter, new research shows.
Read the article:
http://www.internetnews.com/wireless/article.php/3503606
Two Holes Poke Firefox Veneer
[May 9, 2005] And this time they’re deemed ‘extremely critical.’
Read the article:
http://www.internetnews.com/dev-news/article.php/3503506
Qwest Gets Defensive
[May 9, 2005] The telecom will handle Web hosting for a DoD unit under a
10-year contract.
Read the article:
http://www.internetnews.com/infra/article.php/3503516
RFID Tags Work For Waste
[May 9, 2005] UPDATED: A wireless system automatically follows and records
movement of low-level and hazardous waste.
Read the article:
http://www.internetnews.com/wireless/article.php/3503576
IBM, EMC Angle For The Midrange Customer
[May 9, 2005] The competitors in storage offer new servers to tap the market
potential of medium-sized businesses.
Read the article:
http://www.internetnews.com/storage/article.php/3503406
Vonage Remains VC Darling
[May 9, 2005] The VoIP leader amasses $200 million more to fuel its
international expansion.
Read the article:
http://www.internetnews.com/bus-news/article.php/3503401
Court Lowers Broadcast Flag
[May 6, 2005] Appeals panel rules FCC exceeded its authority in rules
designed to limit DTV piracy over Internet.
Read the article:
http://www.internetnews.com/bus-news/article.php/3503306
How Much is Too Much Data Loss?
[May 6, 2005] The rising tide of identity theft.
Read the article:
http://www.internetnews.com/security/article.php/3503331
Microsoft Changes Stand on Gay Issues
[May 6, 2005] Company-wide memo from CEO lays out why Microsoft is switching
its support for gay rights legislation.
Read the article:
http://www.internetnews.com/bus-news/article.php/3503311
Feedback Goodies
***********************************
medium? Ploof! It now is!
If you would like to comment on the newsletter or expand/improve on
something you have seen in here, you can now send your input to:
those relating specifically to this newsletter from all the rest. When you
send email to this address it may wind up being included in this section of
the newsletter, to be shared with your fellow readers. Please don’t send
your questions to this address. They should be sent to our mentors: see
https://www.htmlgoodies.com/mentors/
Windows Tech Goodie of the Week
***********************************
on your web site. The only problem is, these were never meant to be on a web
site! They’ve got URLs in them, but they’re not hyperlinked and the thought
of wading through all that text and adding the appropriate links isn’t
something you’re looking forward to. Well then, this just might be the
script for you…
*** AND ***
Why I Don’t Use DataSets in My ASP.NET Applications
during my talk I mentioned how I, personally, rarely, if ever, use DataSets
in my ASP.NET applications, sticking with the good ol’ DataReader instead.
Read on to learn why I am a DataReader man all the way.
***********************************
Thomas Blood attempted to steal the British Crown Jewels; 1899 the
lawn mower was patented; 1901 Australia opened its first Parliament,
in Melbourne; 1927 the Australian Parliament first convened in its
new capitol, Canberra; 1932 Piccadilly Circus in London was first lit
by electricity; 1949 Prince Rainier III became leader of Monaco;
1962 The Beatles signed their first contract, with EMI Parlophone;
1971 Friends of the Earth returned 1,500 non-returnable bottles to
Schweppes; 1977 Patty Hearst was released from jail; 1980 35
motorists died when a Liberian freighter rammed a bridge in Tampa Bay;
1995 Kinshasa, Zaire was quarantined following an outbreak of the Ebola
virus;
Ferry, John Brown; 1860 Scottish novelist Sir James Matthew Barrie
(Peter Pan); 1873 English archeologist/Egyptologist Howard Carter
(found Tutankhamen’s tomb); English dog training expert Barbara Woodhouse;
1913 Admiral John Hayes; 1930 English actress Joan Sims;
1936 actor Albert Finney; 1936 English actress Glenda Jackson;
1946 actress Candace Bergen; 1949 musician Billy Joel; 1962
actor John Corbet;