Category: JavaScript

How do you submit a form using JavaScript?

January 3, 2010 | Filed Under JavaScript | 1 Comment

The form validation script uses the onsubmit() event of the form to validate the input. The browser does not trigger the onsubmit event if you call the submit method programmatically. Therefore, if the form is using the form validator script, call the onsubmit method also to trigger the validation.

<script src="/scripts/gen_validatorv2.js"
type="text/javascript"></script>

<form id="myform" action="handle-data.php">
Search: <input type='text' name='query' />
<A href="javascript: submitform()">Search</A>
</form>
<script type="text/javascript">
var myformValidator = new Validator("myform");
myformValidator.addValidation("query","req",
        "Please enter the value for query");
</script>

<!-- The function that submits the form-->
<script type="text/javascript">
function submitform()
{
 if(document.myform.onsubmit())
 {//this check triggers the validations
    document.myform.submit();
 }
}
</script>
Article written by urooj

What’s relationship between JavaScript and ECMAScript?

January 3, 2010 | Filed Under JavaScript | Leave a Comment

ECMAScript , the language defined in ECMA – 262, isn ’ t tied to web browsers. In fact, the language
has no methods for input or output whatsoever. ECMA – 262 defines this language as a base upon
which more – robust scripting languages may be built. Web browsers are just one host environment
in which an ECMAScript implementation may exist. A host environment provides the base
implementation of ECMAScript as well as extensions to the language designed to interface with the
environment itself. Extensions, such as the Document Object Model (DOM), use ECMAScript ’ s core
types and syntax to provide additional functionality that ’ s more specific to the environment. Other host environments include ScriptEase and Adobe Flash.

JScript was based on the published documentation from Netscape, so it should have been the same thing as JavaScript 1.0. However, there were a few “features” that Netscape did not publish, as well as some functionality that was not recreated by Microsoft correctly. The result of this is that there are some discrepancies between JScript 1.0 and JavaScript 1.0 in Microsoft’s first generation releases.

Since the release of these initial browsers, JavaScript was submitted and has become a standard, known as ECMAScript 1.0 (ECMA-262), with the European Computer Manufacturers Association (ECMA). Because of this standardization, it is now perceived that JavaScript is Netscape’s implementation of ECMAScript and JScript is Microsoft’s implementation.
Article written by urooj

What is JavaScript?

January 3, 2010 | Filed Under JavaScript | Leave a Comment

JavaScript is a platform-independent, event-driven, interpreted client-side scripting and programming language developed by Netscape Communications Corp. and Sun Microsystems.

JavaScript is a general-purpose programming language designed to let programmers of all skill levels control the behavior of software objects

JavaScript is an object-oriented scripting language used to enable programmatic access to objects within both the client application and other applications.

Article written by urooj

How will you define the variables in javascript?

January 1, 2010 | Filed Under JavaScript | Leave a Comment

To begin your script file, use some JavaScript code to write an HTML heading. You could
write the code as a string directly into the document.write() command, as shown here:


document.write(”<h1>My Name is harry</h1>”);

Article written by urooj

How can you append two strings together in javascript?

January 1, 2010 | Filed Under JavaScript | Leave a Comment
<html>
<head>
<title>Two Sting</title>
<script language="JavaScript">
var A = "country", B = "city";
C = A + B;
alert(C);
</script>
</head>
<body>

</body>
</html>

Article written by urooj

© PHPInterviewQuestion.com 2009 - 2010

eXTReMe Tracker