Contents
Embedding and including
Let's first see a simple example:
<html>
<head>
<title>This is a JavaScript example</title>
<script language="JavaScript">
<!--
document.write("Hello World!");
</script>
</head>
<body> Hi, man! </body>
</html>
Usually, JavaScript code starts with the tag <script language="JavaScript">
and ends with the tag </script>. The code placed between <head>
and </head>. Sometimes, people embed the code in the <body>
tags:
<html>
<head></head>
<body>
<script>
.....// The code embedded in the <body> tags.
</script>
</body>
</html>
Why do we place JavaScript code inside comment fields <!-- and
? It's for ensuring that the Script is not displayed by
old browsers that do not support JavaScript. This is optional, but
considered good practice. The LANGUAGE attribute also is optional,
but recommended. You may specify a particular version of JavaScript:
<script language="JavaScript1.2">
You can use another attribute SRC to include an external file containing
JavaScript code:
<script language="JavaScript" src="hello.js"></script>
For example, shown below is the code of the external file hello.js:
document.write("Hello World!")
The external file is simply a text file containing JavaScript code
with the file name extension ".js". Note:
- Including an external file only functions reliably across platforms
in the version 4 browsers.
- The code can't include tags
<script language...> and </script>,
or you will get an error message.
Back to top
write and writeln
In order to output text in JavaScript you must use write()
or writeln(). Here's an example:
<HTML>
<HEAD>
<TITLE> Welcome to my site</TITLE></HEAD>
<BODY>
<SCRIPT LANGUAGE="JAVASCRIPT">
<!--
document.write("Welcome to my site!");
</SCRIPT>
</BODY>
</HTML>
Note: the document object write is in lowercase as JavaScript is
case sensitive. The difference between write and writeln
is: write just outputs a text, writeln outputs the
text and a line break.
Back to top
Document object
The document object is one of the most important objects of JavaScript.
Shown below is a very simple JavaScript code:
document.write("Hi there.")
In this code, document is the object. write
is the method of this object. Let's have a look at some of the other
methods that the document object possesses.
lastModified
You can always include the last update date
on your page by using the following code:
<script language="JavaScript">
document.write("This page created by John N. Last update:" + document.lastModified);
</script>
All you need to do here is use the lastModified property of the
document. Notice that we used + to put together This
page created by John N. Last update: and document.lastModified.
bgColor and fgColor
Lets try playing around with bgColor
and fgColor:
<script>
document.bgColor="black"
document.fgColor="#336699"
</script>
Back to top
Message Box
alert
There are three message boxes: alert, confirm, and
prompt. Let's look at the first one:
<body>
<script>
window.alert("Welcome to my site!")
</script>
</body>
You can put whatever you want inside the quotation marks.
confirm
An example for confirm box:
window.confirm("Are you sure you want to quit?")
prompt
Prompt box is used to allow a user to enter something
according the promotion:
window.prompt("please enter user name")
In all our examples above, we wrote the box methods as window.alert().
Actually, we could simply write the following instead as:
alert()
confirm()
prompt()
Back to top
Variables and Conditions
Let's see an example:
<script>
var x=window.confirm("Are you sure you want to quit")
if (x)
window.alert("Thank you.")
else
window.alert("Good choice.")
</script>
There are several concepts that we should know. First of all, var
x= is a variable declaration. If you want to create a variable,
you must declare the variable using the var statement. x will
get the result, namely, true or false. Then
we use a condition statement if else to give the script
the ability to choose between two paths, depending on this result
(condition for the following action). If the result is true (the user
clicked "ok"), "Thank you" appears in the window box. If the
result is false (the user clicked "cancel"), "Good
choice" appears in the window box instead. So we can make more complex boxes
using var, if and those basic methods.
<script>
var y=window.prompt("please enter your name")
window.alert(y)
</script>
Another example:
<html><head>
<script>
var x=confirm("Are you sure you want to quit?")
if (!x)
window.location="http://www.yahoo.com"
</script>
</head>
<body>
Welcome to my website!.
</body></html>
If you click "cancel", it will take you to yahoo, and clicking
ok will continue with the loading of the current page "Welcome
to my website!". Note:if (!x)means: if click "cancel".
In JavaScript, the exclamation mark ! means: "none".
Back to top
Function
Functions are chunks of code.Let's create a simple function:
function test()
{
document.write("Hello can you see me?")
}
Note that if only this were within your <script></script>
tags, you will not see "Hello can you see me?" on your
screen because functions are not executed by themselves until you
call upon them. So we should do something:
function test()
{
document.write("Hello can you see me?")
}
test()
Last linetest() calls the function, now you
will see the words "Hello can you see me?".
Back to top
Event handler
What are event handlers? They can be considered as triggers that
execute JavaScript when something happens, such as click or move
your mouse over a link, submit a form etc.
onClick
onClick handlers execute something only when users
click on buttons, links, etc. Let's see an example:
<script>
function ss()
{
alert("Thank you!")
}
</script>
<form>
<input type="button" value="Click here" onclick="ss()">
</form>
The function ss() is invoked when the user clicks the button. Note:
Event handlers are not added inside the <script> tags, but
rather, inside the html tags.
onLoad
The onload event handler is used to call the execution
of JavaScript after loading:
<body onload="ss()">
<frameset onload="ss()">
<img src="whatever.gif" onload="ss()">
onMouseover,onMouseout
These handlers are used exclusively
with links.
<a href="#" onMouseOver="document.write('Hi, nice to see you!">Over Here!</a>
<a href="#" onMouseOut="alert('Good try!')">Get Out Here!</a>
onUnload
onunload executes JavaScript while someone leaves
the page. For example to thank users.
<body onunload="alert('Thank you for visiting us. See you soon')">
Handle multiple actions
How do you have an event handler
call multiple functions/statements? That's simple. You just need
to embed the functions inside the event handler as usual, but separate
each of them using a semicolon:
<form>
<input type="button" value="Click here!" onClick="alert('Thanks
for visiting my site!');window.location='http://www.yahoo.com'">
</form>
Back to top
Form
Let's say you have a form like this:
<form name="aa">
<input type="text" size="10" value="" name="bb"><br>
<input type="button"
value="Click Here"onclick="alert(document.aa.bb.value)">
</form>
Notice that we gave the names to the form and the element. So JavaScript
can gain access to them.
onBlur
If you want to get information from users and want
to check each element (ie: user name, password, email) individually,
and alert the user to correct the wrong input before moving on,
you can use onBlur. Let's see how onblur works:
<html><head><script>
function emailchk()
{
var x=document.feedback.email.value
if (x.indexOf("@")==-1)
{
alert("It seems you entered an invalid email address.")
document.feedback.email.focus()
}
}
</script></head><body>
<form
name="feedback">
Email:<input type="text" size="20" name="email"
onblur="emailchk()"><br>
Comment: <textarea name="comment" rows="2" cols="20"></textarea><br>
<input type="submit" value="Submit">
</form>
</body></html>
If you enter an email address without the @, you'll
get an alert asking you to re-enter the data. What is: x.indexOf(@)==-1?
This is a method that JavaScript can search every character within
a string and look for what we want. If it finds it will return the
position of the char within the string. If it doesn't, it will return
-1. Therefore, x.indexOf("@")==-1 basically
means: "if the string doesn't include @, then:
alert("It seems you entered an invalid email address.")
document.feedback.email.focus()
What's focus()? This is a method of the text box, which basically
forces the cursor to be at the specified text box.
onsubmit Unlike onblur, onsubmit
handler is inserted inside the <form> tag, and not inside
any one element. Lets do an example:
<script>
<!--
function validate()
{
if(document.login.userName.value=="")
{
alert ("Please enter User Name")
return false
}
if(document.login.password.value=="")
{
alert ("Please enter Password")
return false
}
}
</script>
<form name="login" onsubmit="return validate()">
<input type="text" size="20" name="userName">
<input type="text" size="20" name="password">
<input type="submit" name="submit" value="Submit">
</form>
Note:
if(document.login.userName.value==""). This means
"If the box named userName of the form named login contains
nothing, then...". return false. This is used to stop the
form from submitting. By default, a form will return true if submitting.
return validate() That means, "if submitting, then call
the function validate()".
Protect a file by using Login
Let's try an example
<html><head>
<SCRIPT Language="JavaScript">
function checkLogin(x)
{
if ((x.id.value != "Sam")||(x.pass.value !="Sam123"))
{
alert("Invalid Login");
return false;
}
else
location="main.htm"
}
</script>
</head><body>
<form>
<p>UserID:<input type="text" name="id"></p>
<p>Password:<input type="password" name="pass"></p>
<p><input type="button" value="Login" onClick="checkLogin(this.form)"></p>
</form>
</body></html>
|| means "or", and ,!= indicates
"not equal". So we can explain the script: "If the
id does not equal 'Sam', or the password does not equal 'Sam123', then
show an alert ('Invalid Login') and stop submitting. Else, open the
page 'main.htm'".
Back to top
Link
In most cases, a form can be repaced by a link:
<a href="JavaScript:window.location.reload()">Click to reload!</a>
More examples:
<a href="#" onClick="alert('Hello, world!')">Click me to say Hello</a><br>
<a href="#" onMouseOver="location='main.htm'">Mouse over to see Main Page</a>
Back to top
Date
Let's see an example:
<HTML><HEAD><TITLE>Show
Date</TITLE></HEAD>
<BODY>
<SCRIPT LANGUAGE="JavaScript">
var x= new Date();
document.write (x);
</SCRIPT>
</BODY></HTML>
To activate a Date Object, you can do this: var x=new Date(). Whenever
you want to create an instance of the date object, use this important
word: new followed by the object name().
Dynamically display different pages
You can display different
pages according to the different time. Here is an example:
var banTime= new Date()
var ss=banTime.getHours()
if (ss<=12)
document.write("<img src='banner1.gif'>")
else
document.write("<img src='banner2.gif'>")
Date
object
| Methods |
getDate
getTime
getTimezoneOffset
|
getDay
getMonth
getYear
|
getSeconds
getMinutes
getHours |
Back to top
Window
Open a window
To open a window, simply use the method "window.open()":
<form>
<input type="button" value="Click here to see" onclick="window.open('test.htm')">
</form>
You can replace test.htm with any URL, for example,
with http:.
Size, toolbar, menubar, scrollbars, location, status
Let's
add some of attributes to the above script to control the size of
the window, and show: toolbar, scrollbars etc. The syntax to add
attributes is:
open("URL","name","attributes")
For example:
<form>
<input type="button" value="Click here to see"
onclick="window.open('page2.htm','win1','width=200,height=200,menubar')">
</form>
Another example with no attributes turned on, except the size changed:
<form>
<input type="button" value="Click here to see"
onclick="window.open('page2.htm','win1','width=200,height=200')">
</form>
Here is the complete list of attributes you can add:
| width |
height |
toolbar |
| location |
directories |
status |
| scrollbars |
resizable |
menubar |
Reload
To reload a window, use this method:
window.location.reload()
Close Window
Your can use one of the codes shown below:
<form>
<input type="button" value="Close Window" onClick="window.close()">
</form>
<a href="javascript:window.close()">Close Window</a>
Loading
The basic syntax when loading new content into a
window is:
window.location="test.htm"
This is the same as
<a href="test.htm>Try this </a>
Let's provide an example, where a confirm box will allow users
to choose between going to two places:
<script>
<!--
function ss()
{
var ok=confirm('Click "OK" to go to yahoo, "CANCEL" to go to hotmail')
if (ok)
location="http://www.yahoo.com"
else
location="http://www.hotmail.com"
}
</script>
Remote Control Window
Let's say you have opened a new window
from the current window. After that, you will wonder how to make
a control between the two windows. To do this, we need to first
give a name to the window.Look at below:
aa=window.open('test.htm','','width=200,height=200')
By giving this window a name "aa", it will give you access
to anything that's inside this window from other windows. Whenever
we want to access anything that's inside this newly opened window,
for example, to write to this window, we would do this: aa.document.write("This
is a test.").
Now, let's see an example of how to change the background color
of another window:
<html><head><title></title></head>
<body>
<form>
<input type="button" value="Open another page"
onClick="aa=window.open('test.htm','','width=200,height=200')">
<input type="radio" name="x" onClick="aa.document.bgColor='red'">
<input type="radio" name="x" onClick="aa.document.bgColor='green'">
<input type="radio" name="x" onClick="aa.document.bgColor='yellow'">
</form>
</body></html>
opener
Using "opener" property, we can access
the main window from the newly opened window.
Let's create Main page:
<html>
<head>
<title></title>
</head>
<body>
<form>
<input type="button" value="Open another page"
onClick="aa=window.open('test.htm','','width=100,height=200')">
</form>
</body>
</html>
Then create Remote control page (in this example, that is test.htm):
<html>
<head>
<title></title>
<script>
function remote(url){
window.opener.location=url
}
</script>
</head>
<body>
<p><a href="#" onClick="remote('file1.htm')">File
1</a></p>
<p><a href="#" onClick="remote('file2.htm')">File
2</a></p>
</body>
</html>
Try it now!
Back to top
Frame
One of the most popular uses of loading multiple frames is to load
and change the content of more than one frame at once. Lets say
we have a parent frame:
<html>
<frameset cols="150,*">
<frame src="page1.htm" name="frame1">
<frame src="page2.htm" name="frame2">
</frameset>
</html>
We can add a link in the child frame "frame1" that will
change the contents of not only page1, but page2 too. Shown below is
the html code for it:
<html>
<body>
<h2>This is page 1 </h2>
<a href="page3.htm"
onClick="parent.frame2.location='page4.htm'">Click Here</a>
</body>
</html>
Notice: You should use "parent.frameName.location" to
access another frame. "parent" standards for the parent
frame containing the frameset code.
Back to top
| You must Sign In to use this message board. |
|
|
 |
|
 |
Hello all, Iam new to asp.net & javascript, sorry if my post is in wrong area. Iam strucked by one problem in javascript. My problem is iam trying to add textboxes and button dynamically.iam doing that by using javascript. I done it, iam able to add the textbox and remove the textbox by clicking the button(generated dynamically). Iam doing it by using . for removing textbox i just deletng the row. but deleting row from the table,starts from the lastrow but not at required row. How can i notice or catch the particular button in a particular row is clicked and how can i pass that 'row id' or 'button id' to the RemoveRow() function(which is in javascript).
Pls let me know whether my problem is understand.
Thanks in advance Rajesh
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
 |
Don't teach new users to Javascript to validate login information by checking against the actual string text of the usernames + passwords. Tutorials like this are the reason why there is zero security on the web.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
I need to pass a url from a primary page that contains records with recordID's, upon sending URL string to the next page with recordID I would like for that to be captured so that the page onload instantly goes/zooms to that record. Can anyone help with this?
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
 |
You can copy the whole script to run at your html page.
My problem ---------- I able to dynamically add the textbox field, and the remove link
However, I failed to remove the hyperlink when i click remove.
What I want is: remove both the textbox and hyperlink for the row when I click the remove link.
Help.....
<script type="text/javascript" language="javascript">
function CreateInputElement(elementType){
var numi= document.getElementById('hCounter'); //get from HiddenField to do counter increment var num= (document.getElementById('hCounter').value -1) + 2; numi.value= num;
var IdName= 'txt' + num; //dynamic div
var mydiv = document.getElementById("mycontentdiv"); var btn = document.createElement("input"); btn.setAttribute("id", IdName);
btn.setAttribute("type", elementType); btn.setAttribute("value", "click you"); btn.onclick = function(){this.value="i have been clicked!";}; mydiv.appendChild(btn); var x= document.createElement("br");
var aid= "a" + IdName; var hyperlink = document.createElement("a"); hyperlink.setAttribute("href","#"); hyperlink.setAttribute("id", aid); hyperlink.onclick= function() { alert('hehe'); removeOtherElement(IdName); } hyperlink.appendChild(document.createTextNode("Remove")); mydiv.appendChild(hyperlink); mydiv.appendChild(x); }
function removeOtherElement(IdNum) { var d= document.getElementById('mycontentdiv'); var olddiv= document.getElementById(IdNum); d.removeChild(olddiv); } </script>
<form id="Form1">
<input type="hidden" value="0" id="hCounter" />
Add Another Field
</form>
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
I Have created a Web Application in ASP.NET 2.0, my requirement is to get the user system information.
i.e. when the user logons to the webpage, In the home page i have to read the system information (Like OS, OSVERSION, MANUFACTURER.)..
Is it possible to do in Javascript.. If it is not possible in Javascript then is there any other way to this..??
modified on Thursday, May 29, 2008 7:31 AM
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
 |
I have created a virtual keyboard in javascript which will be used in place of keyboard to enter information in a web page.. this keyboard is embedded in d browser and hence is independent of d page and its content.. m not able to get d currently focused text box to input data so dat my input will be directed to that text input field.... so PLZ PLZ help me....
|
| Sign In·View Thread·PermaLink | 1.00/5 |
|
|
|
 |
|
 |
Hi Every one. This is my first posting to this forum. i realy find this Code project helpful for my technical problem. I want to update my server side database with client side databse. Is there any possible sollution to get of out of it?
help me
|
| Sign In·View Thread·PermaLink | 1.67/5 |
|
|
|
 |
|
|
 |
|
|
 |
|
 |
hi, i want to open a popup window from an aspx form which should contain the content from the server . is there any way to pass the content to the popup window. also i have to print the content of the popup and return a variable indicating that the doucmnet is printed. is it possible. i m new to javascript in asp.net. please help
|
| Sign In·View Thread·PermaLink | 2.00/5 |
|
|
|
 |
|
|
 |
|
 |
So nice article.As a beginner programmer sometimes i need to refer this type of article.Your article "JavaScript For Beginners " helped me to know more about JavaScript.Thank you......
Rajeev KTS InfoTech[^]
www.ktsinfotech.com
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
I need to compare two fields in a form. I have one textarea for Email and then another textarea for the user to re-enter their email address. I need a code to compare the two.
LaineGenna www.lainegennadesigns.com
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Hello, I am new to Javascript. I have a form where I have to add new fields and delete the generated fields. Here is my javascript...please copy it into an html file. I can add multiple text fields when I click Add Property, and respectively Add PIDs (tables) when I click Add PID. I am having trouble in deleting the generated form fields when the user selects the fields he want to delete. I am calling the function DeletePropertyTable1 (pidNum) pidNum is the number of PIDS..Please let me know if you have any clues how to do it. Thanks.
this is the function I am having problem with. I am passing the pidNum (number of outer tables created)...the user will generate more fields by clicking "Add Property" button. and selects the fields he wants to delete and clicks "Delete Property" button. Delete Property works for the first table, the one that is default. for the second dynamically generated table I am not able to delete the properties. In order to get the number of checkboxes selected I need to get the name of the checkbox..for example, propertyname1, propertyname2..and so on..I should get the length of the checkbox (number of checkboxes and the ones that are checked). Please let me know if this does not make sense. Thanks in advance.
function DeletePropertyTable1 (pidNum) { var counter3=0; var propname = 'propertyname' +pidNum; var propid = 'Property'+pidNum; var existing4 = document.getElementById(propid); }
please copy it to a html file and run it.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD> <META http-equiv=Content-Type content="text/html; charset=windows-1252">
<SCRIPT type=text/javascript> var NumAdded = 0; var numPIDS = 1;
function AddPropertyTable() {
var existing = document.getElementById('Property'); NumAdded++; var newdiv = document.createElement('div'); var divIdName = 'Div' + NumAdded; newdiv.setAttribute('id',divIdName); //alert(divIdName); var upid2 = 0; //var propertTable ='| Agent Property | <INPUT type="text" name=AgentPropName' + upid2 +' size="40"> |
|---|
| Property Value | <INPUT type="text" name=AgentPropValue' + upid2 +' size="40"> |
|---|
'; var propertTable =' | <INPUT type="checkbox" name="propertyname" value='+ divIdName +'> | <INPUT type="text" name="AgentPropName0" id= "rpropname" size= "32"> | <INPUT type ="text" name="AgentPropValue0" id="propval" size="32"> | ';
newdiv.innerHTML +=(propertTable);
existing.appendChild(newdiv);
}
function AddPropertyTable1(upid) { NumAdded++; var existing2 = document.getElementById('Property'+upid); var newdiv2 = document.createElement('div'); var divIdName = 'Div' + NumAdded; var chk = 'chk'+NumAdded; newdiv2.setAttribute('id',divIdName); alert (divIdName); var upid1 = upid; //alert(upid); //alert(newdiv2); //var propertTable ='| Agent Property | <INPUT type="text" name=AgentPropName' + upid1 +' size="40"> |
|---|
| Property Value | <INPUT type="text" name=AgentPropValue' + upid1 +' size="40"> |
|---|
'; var propertTable =' | <INPUT type="checkbox" name=propertyname' + upid1 +' value='+ chk +'> | <INPUT type="text" name="AgentPropName0" id= "rpropname" size= "32"> | <INPUT type ="text" name="AgentPropValue0" id="propval" size="32"> | '; newdiv2.innerHTML +=(propertTable);
existing2.appendChild(newdiv2); }
function AddPIDTable () { numPIDS++; var existingPID= document.getElementById('PIDID'); var newdiv1= document.createElement('div'); var divIdName1 = 'DIV' + numPIDS; newdiv1.setAttribute('id',divIdName1); //alert(divIdName1); //alert(numPIDS);
//var pidTable= '
| <INPUT type="checkbox" name=PID' + numPIDS +' value=""> | <LABEL for="pid">PID</LABEL> | <INPUT type="text" name=PackageId' + numPIDS +' id="pid" value="" size="40"> | <INPUT type="checkbox" name=FactoryPID' + numPIDS +' value=""> | <LABEL for="facpid">Factory PID</LABEL> | Optionally, specify bundle name and version to enable software distribution <LABEL for="bname">Bundle Name</LABEL> <INPUT type="text" name=BundleName' + numPIDS +' id="bname" value="" size="20"> <LABEL for="bversion">Bundle Version</LABEL> <INPUT type="text" name=BundleVersion' + numPIDS +' id="bversion" value="" size="5"> <INPUT type="checkbox" name=CreateSoftware'+numPIDS+' value=""> <LABEL for="facpid">Create Software Distribution Job?</LABEL>
| <LABEL for ="rpropname">Agent Property</LABEL> | <INPUT type="text" name="AgentPropName0" id= "rpropname" size= "40"> | | <LABEL for ="propopval"> Property Value</LABEL> | <INPUT type ="text" name="AgentPropValue0" id="propval" size="40"> | <INPUT type="button" name="AddProperty" value="Add property" önClick="AddPropertyTable1('+numPIDS+');">'; var pidTable= '
| <INPUT type="checkbox" name="Pidnumber" value=' + divIdName1 + '> | <LABEL for="pid">PID</LABEL> | <INPUT type="text" name=PackageId' + numPIDS +' id="pid" value="" size="40"> | <INPUT type="checkbox" name=FactoryPID' + numPIDS +' value=""> | <LABEL for="facpid">Factory PID</LABEL> | Optionally, specify bundle name and version to enable software distribution <LABEL for="bname">Bundle Name</LABEL> <INPUT type="text" name=BundleName' + numPIDS +' id="bname" value="" size="20"> <LABEL for="bversion">Bundle Version</LABEL> <INPUT type="text" name=BundleVersion' + numPIDS +' id="bversion" value="" size="5"> <INPUT type="checkbox" name=CreateSoftware'+numPIDS+' value=""> <LABEL for="facpid">Create Software Distribution Job?</LABEL> | | <LABEL for ="rpropname">Name</LABEL> | <LABEL for ="propval">Value</LABEL> | | <INPUT type="checkbox" name=propertyname'+ numPIDS +' value=""> | <INPUT type="text" name="AgentPropName0" id= "rpropname" size= "32"> | <INPUT type ="text" name="AgentPropValue0" id="propval" size="32"> | <INPUT type="button" name="AddProperty" value="Add property" önClick="AddPropertyTable1('+numPIDS+');"> <INPUT type="button" name="DeleteProperty" value="Delete property" önClick="DeletePropertyTable1('+numPIDS+');">'; newdiv1.innerHTML +=(pidTable);
existingPID.appendChild(newdiv1); document.BundlePropertiesForm.pids.value=numPIDS; }
function DeletePropertyTable () {
var existing2 = document.getElementById ('Property'); var counter = 0;
if (typeof(BundlePropertiesForm.propertyname.length) == "undefined"){ BundlePropertiesForm.propertyname = [BundlePropertiesForm.propertyname]; deleted=document.getElementById(BundlePropertiesForm.propertyname.value); existing2.removeChild (deleted); } var twoDimArray = new Array (BundlePropertiesForm.propertyname.length);
for(var num = 0; num < BundlePropertiesForm.propertyname.length; num++) { var deleted; if(BundlePropertiesForm.propertyname[num].checked){ twoDimArray[counter] = BundlePropertiesForm.propertyname[num].value; counter++; } } for (count = 0; count < counter; count++ ) { existing2.removeChild(document.getElementById(twoDimArray[count] ) ); }
}
function DeletePropertyTable1 (pidNum) { var counter3=0; var propname = 'propertyname' +pidNum;
var propid = 'Property'+pidNum;
var existing4 = document.getElementById(propid);
}
function DeletePIDTable () { //alert("inside the deleting pid table" ); var existing3 = document.getElementById("PIDID"); var counter1= 0;
if (typeof(BundlePropertiesForm.Pidnumber.length) == "undefined"){ BundlePropertiesForm.Pidnumber = [BundlePropertiesForm.Pidnumber]; deleted=document.getElementById(BundlePropertiesForm.Pidnumber.value); existing3.removeChild (deleted); } var twoDimArray1 = new Array (BundlePropertiesForm.Pidnumber.length);
for(var num = 0; num < BundlePropertiesForm.Pidnumber.length; num++) { var deleted; if(BundlePropertiesForm.Pidnumber[num].checked){ twoDimArray1[counter1] = BundlePropertiesForm.Pidnumber[num].value; counter1++; } } for (count = 0; count < counter1; count++ ) { existing3.removeChild(document.getElementById(twoDimArray1[count] ) ); }
}
</SCRIPT>
<META content="MSHTML 6.00.2900.2995" name=GENERATOR></HEAD> <BODY> <FORM name=BundlePropertiesForm><INPUT type=checkbox value="" name=PIDdddd>
<LABEL for=pid>Package Id</LABEL> | <INPUT id=pid size=54 name=PackageId> |
|---|
<LABEL for=bname>Bundle Name</LABEL> | <INPUT id=bname size=54 name=BundleName> |
|---|
<LABEL for=rpropname>Agent Property</LABEL> TH> | <INPUT id=rpropname size=60 name=AgentPropName> |
|---|
<LABEL for=propval>Property Value</LABEL> TH> | <INPUT id=propval size=60 name=AgentPropValue> |
|---|
<input type="hidden" name="pids" value="" id="pids">
<INPUT önclick=AddPropertyTable(); type=button value="Add property" name=AddProperty> <INPUT type="button" name="DeleteProperty" value="Delete property" önClick="DeletePropertyTable();">
<INPUT type="button" name="AddPID" value="Add PID" önClick="AddPIDTable();"> <INPUT type="button" name="action" value="DELETE Selected PID" önClick="DeletePIDTable();">
<INPUT type=submit value=add name=action> </FORM></BODY></HTML>
|
| Sign In·View Thread·PermaLink | 1.50/5 |
|
|
|
 |
|
 |
I am trying to have a graphic be able to be dragged and dropped. I would like some tips on how to: -specify a location where the graphic is to be dropped to -Have the graphic snap back to its original location if the user does not drag it to the designated location? -Create a cool-looking "grabber" to let the user know that they have grabbed the graphic and are ready to drag and drop it?
|
| Sign In·View Thread·PermaLink | 1.71/5 |
|
|
|
 |
|
 |
U need ajax, it's javascript + XML try googling ajax articles or projects and u'll find what u need 
Best Regards 3ala2 
|
| Sign In·View Thread·PermaLink | 1.00/5 |
|
|
|
 |
|
 |
just3ala2 wrote: U need ajax,
Complete rubbish - there's no need to use Ajax to implement drag & drop (Although the ASP.NET Ajax stuff does include D&D functionality). It's done by looking at the object's style.top and style.left attributes and modifying accordingly.
To create a "grabber" over draggable objects, use something like element.onmouseover="this.style.cursor='hand'"
To snap back to the original location, store the top and left at start, and if a condition isn't met on the drop, then just set them back to where they started from
C# has already designed away most of the tedium of C++.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
hi, how to call 2 js functions for a single event ie. on blur i need to call 2 js functions where they return boolean.
Karts
|
| Sign In·View Thread·PermaLink | 1.67/5 |
|
|
|
 |
|
 |
Hi there
<... önblur="function1();function2();"> Or <... önblur="return function1();function2();">
hope this would help
Best Regards 3ala2 
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Thanks but how we can load contnt dynamicly like in google mail where the menus reamin in place but contnt change dynamicly pleas help
The best stay at lest of war
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
 |
Does anyone know if it is possible to set the cancel button to be the default (have focus) when using a javascript confirm box?
rmaringer
|
| Sign In·View Thread·PermaLink | 2.17/5 |
|
|
|
 |
|
|
|