Hi there, Amirehsans!
I have a fair amount of Javascript/HTML experience and I'll answer
these in the original order with notes under each example.
You'll have to watch out for word wrapping in these code examples,
especially No 3.
======
1.
Script:
<head>
<script type="text/javascript">
function dofunction()
{
alert("Alert Box")
}
</script>
</head>
<a href="nonscriptedpage.html" onclick="dofunction(); return
false;">Click to call event</a>
Explanation:
In the <head> we have a standard function which is then called when
the link is clicked on using the Onclick event handler.
Other event handlers include OnMouseUp, OnMouseDown, OnMouseOver and
OnMouseOut.
The "nonscriptedpage.html" part is for any browsers which have
Javascript disabled, the "return false;" statement will stop
the actual "href" part from executing on Javascript enabled browsers.
For more, see here: http://lists.evolt.org/archive/Week-of-Mon-19991227/093578.html
======
2.
Script:
<!--[if IE]>
<a href="#" onclick="this.style.behavior='url(#default#homepage)';
this.setHomePage('http://www.yoursite.com');">Set as homepage!</a>
<![endif]-->
Explanation:
This short code will only work in Internet Explorer 5+ and will make
the standard "Set as Homepage?" dialog box appear.
======
3.
Script:
<html>
<head>
<script type="text/javascript">
function calculate() {
// Textbox D which is A + B
x=eval(document.calcscript.a.value)
y=eval(document.calcscript.b.value)
ab=x+y
document.calcscript.d.value = ab
// Textbox C which is A * 50 + B * 14
a50=document.calcscript.a.value * 50 // Change these parts
b14=document.calcscript.b.value * 14 // for different
multiplications
z = a50 + b14
document.calcscript.c.value = z
}
</script>
</head>
<body>
<div align="center">
<h1>Calculator</h1>
<form name="calcscript">
<h2>A</h2>
<select name="a">
<option>2</option>
<option>10</option>
<option>500</option>
<option>2000</option>
</select>
<h2>B</h2>
<select name="b">
<option>4</option>
<option>20</option>
<option>100</option>
<option>7000</option>
</select>
<h2>C</h2>
<input type="text" size="10" name="c">
<h2>D</h2>
Total cost for X months and Y weeks is: <input type="text" size="10"
name="d">
<h2>Calculate!</h2>
<input type="button" value="Calculate" onClick="calculate()">
</form>
</div>
</body>
</html>
Explanation:
I included some notes in the script itself.
As you can see, the first part basically says:
"X is the option you select in the form object A, same goes for B.
Then, AB is A + B. Lastly, make the forum object D have
the value of AB."
Simply copy and paste the lot into a text editor, save as a .html file
then open it in your browser to test.
======
It was a pleasure to code these for you.
I don't have anything in the way of links or searches unfortunately
because I knew how to code these but if you need any clarification,
don't hesitate to ask.
Kind regards,
errol-ga. |