473,394 Members | 1,879 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

What does this code mean ?

Someone please translate the code below into English...
Particularly the indicated line
Thanks
function attachComment()
{
var aForms = document.getElementsByTagName("FORM");
for (var i = 0; i < aForms.length; i++)
{
var oForm = aForms[i];
if (/comment_fieldset/.test(oForm.className)) // <--- WHAT DOES THIS
LINE MEAN ?
{
oForm.onsubmit = function()
{
return addComment(this);
}
}
}
}
Jul 23 '05 #1
3 6626


RobertTG wrote:
Someone please translate the code below into English...
Particularly the indicated line
Thanks
function attachComment()
{
var aForms = document.getElementsByTagName("FORM");
for (var i = 0; i < aForms.length; i++)
{
var oForm = aForms[i];
if (/comment_fieldset/.test(oForm.className)) // <--- WHAT DOES THIS
LINE MEAN ?
{
oForm.onsubmit = function()
{
return addComment(this);
}
}
}
}


/comment_fieldset/ is a Regular Expression Object object, and test is
one of the methods of it.

see this:

Microsoft® JScript®
test Method Language Reference
Version 3
See Also Applies To
--------------------------------------------------------------------------------

Description
Returns a Boolean value that indicates whether or not a pattern exists
in a searched string.
Syntax
rgexp.test(str)
The test method syntax has these parts:

Part Description
rgexp Required. A Regular Expression object. Can be a variable name or
a literal.
str Required. The string to test a search on.
Remarks
The test method checks to see if a pattern exists within a string and
returns true if so, and false otherwise.
The RegExp object is not modified by the test method.

The following example illustrates the use of the test method:
function TestDemo(re, s)
{
var s1;
// Test string for existence of regular expression.
if (re.test(s))
s1 = " contains ";
else
s1 = " does not contain ";
// Get text of the regular expression itself.
return(s + s1 + re.source);
}

Jul 23 '05 #2
"RobertTG" <rt*@mailinator.com> wrote in message
news:d7**********@reader1.panix.com...
Someone please translate the code below into English...
Particularly the indicated line
Thanks
function attachComment()
{
var aForms = document.getElementsByTagName("FORM");
for (var i = 0; i < aForms.length; i++)
{
var oForm = aForms[i];
if (/comment_fieldset/.test(oForm.className)) // <--- WHAT DOES THIS
LINE MEAN ?
{
oForm.onsubmit = function()
{
return addComment(this);
}
}
}
}


Hi Robert,

I believe the line of code you are referring to checks if the className
contains the text "comment_fieldset".

Check out
http://msdn.microsoft.com/library/en...asp?frame=true

Regards,
John MacIntyre
http://www.johnmacintyre.ca
Specializing in; Database, Web-Applications, and Windows Software
Jul 23 '05 #3
RobertTG wrote:
Someone please translate the code below into English...
Particularly the indicated line
Thanks
function attachComment()
{
var aForms = document.getElementsByTagName("FORM");
A collection of the documents forms is 'put into' the variable
'aForms', which is now a kind of array so that aForms[0] references the
first form in the document, aForms[1] the second, etc.
for (var i = 0; i < aForms.length; i++)
{
var oForm = aForms[i];
For every form that is referenced by aForms...
if (/comment_fieldset/.test(oForm.className)) // <--- WHAT DOES THIS
LINE MEAN ?
if the classname if the form contains the text 'comment_fieldset'...
{
oForm.onsubmit = function()
{
return addComment(this);
}
attach the function 'addComment()' to the onsubmit handler with
a reference to the form as a parameter ('this' will refer to the
form that is being submitted).

When the form is submitted, addComment() runs and probably returns
either true or false depending on the outcome of whatever it does.
Whatever value addComment() returns is returned to the onsubmit
handler, and if it's 'false', the form will not be submitted.
}
}
}

--
Rob
Jul 23 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

220
by: Brandon J. Van Every | last post by:
What's better about Ruby than Python? I'm sure there's something. What is it? This is not a troll. I'm language shopping and I want people's answers. I don't know beans about Ruby or have...
125
by: Sarah Tanembaum | last post by:
Beside its an opensource and supported by community, what's the fundamental differences between PostgreSQL and those high-price commercial database (and some are bloated such as Oracle) from...
44
by: lester | last post by:
a pre-beginner's question: what is the pros and cons of .net, compared to ++ I am wondering what can I get if I continue to learn C# after I have learned C --> C++ --> C# ?? I think there...
121
by: typingcat | last post by:
First of all, I'm an Asian and I need to input Japanese, Korean and so on. I've tried many PHP IDEs today, but almost non of them supported Unicode (UTF-8) file. I've found that the only Unicode...
51
by: jacob navia | last post by:
I would like to add at the beginning of the C tutorial I am writing a short blurb about what "types" are. I came up with the following text. Please can you comment? Did I miss something? Is...
58
by: Larry David | last post by:
Ok, first of all, let's get the obvious stuff out of the way. I'm an idiot. So please indulge me for a moment. Consider it an act of "community service".... What does "64bit" mean to your friendly...
13
by: Jason Huang | last post by:
Hi, Would someone explain the following coding more detail for me? What's the ( ) for? CurrentText = (TextBox)e.Item.Cells.Controls; Thanks. Jason
669
by: Xah Lee | last post by:
in March, i posted a essay “What is Expressiveness in a Computer Language”, archived at: http://xahlee.org/perl-python/what_is_expresiveness.html I was informed then that there is a academic...
16
by: utab | last post by:
Dear all, In programming terminology, what is a wrapper and where is it used? Regards
13
by: Protoman | last post by:
I'm getting an error: 10 C:\Dev-Cpp\Enigma.cpp no match for 'operator<' in 'i < (+cleartext)->std::basic_string<_CharT, _Traits, _Alloc>::end ()' Code: Enigma.hpp...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.