');
}) });
" + carOrder + "
"; } Blue Car: Red Car: Green Car:setTimeout(function() {
alert('test')
}, 5000);
function addEventHandler(Node, evt, Func, Captures) {
if (document.addEventListener) {
// Safari, Chrome, Fx, etc
Node.addEventListener(evt, Func, Captures);
} else {
// IE
Node.attachEvent('on' + evt, Func);
}
}
function onLinkClicked(e) {
alert("You clicked the link!");
}
function setUpClickEvent(e) {
addEventHandler(document.getElementById('butt1'), 'click', onLinkClicked, false);
}
window.onload = setUpClickEvent
function newContent(){ var divTag = document.createElement("div"); divTag.id = "div1"; divTag.setAttribute("align","center"); divTag.style.margin = "0px auto"; divTag.className ="dynamicDiv"; divTag.innerHTML = "This HTML Div tag created using Javascript DOM dynamically."; document.body.appendChild(divTag); };
function removeNode(){
var child = document.getElementById('alpha');
var parent = document.getElementById('two');
parent.removeChild(child);
}
function myFunc(){
var i =0;
for(i=0; i<= picArray.length; i++)
{ var value = picArray[i];
document.write(value + '<br />');
}
}
document.write("<h1>Multiplication table</h1>");
document.write("<table border=2 width=50%");
for (var i = 1; i <= 9; i++ ) { //this is the outer loop
document.write("<tr>");
document.write("<td>" + i + "</td>");
for ( var j = 2; j <= 9; j++ ) { // inner loop
document.write("<td>" + i * j + "</td>");
}
document.write("</tr>");
}
document.write("</table>");
<script type="text/javascript">
function howMany (selectItem) {
var numberSelected=0
for (var i=0; i < selectItem.options.length; i++) {
if (selectItem.options[i].selected == true)
numberSelected++;
}
return numberSelected
}
</script>
<form name="selectForm">
<p>Choose some book types, then click the button below:</p>
<select multiple name="bookTypes" size="8">
<option selected> Classic </option>
<option> Information Books </option>
<option> Fantasy </option>
<option> Mystery </option>
<option> Poetry </option>
<option> Humor </option>
<option> Biography </option>
<option> Fiction </option>
</select>
<input type="button" value="How many are selected?"
onclick="alert ('Number of options selected: ' + howMany(document.selectForm.bookTypes))">
</form>
?php
// Make a MySQL Connection
mysql_connect("host", "user", "password") or die(mysql_error());
mysql_select_db("test") or die(mysql_error());
// Retrieve all the data from the "example" table
$result = mysql_query("SELECT * FROM example")
or die(mysql_error());
$row = mysql_fetch_array( $result );// store the record of the "example" table
into $row // Print out the contents of the entry
echo "Name: ".$row['name'];
echo " Age: ".$row['age'];
?>
var b = document.getElementById('blue').value; var b1 = Number(b);
(ABOVE FOR FORM)
var i = '12';
function myFunc(){
alert(i);
alert(typeof i);
i = Number(i);
alert(typeof i);
alert(i);
i = String(i);
alert(typeof i);
alert(i);
}
$(function(){ $.each(/*picArray*/[52, 97], function(index, value) { alert(index + ': ' + value); }); })
$(document.body).click(function () {
$("div").each(function () {
if (this.style.color != "blue") {
this.style.color = "blue";
} else {
this.style.color = "";
}
});
});
$(function(){
$('li:odd').each(function(){
$(this).css("background-color","orange");
$(this).fadeOut(2000);
})
})
---------------
$('a').each(function(index, value){
$('#myDiv').append('
' + $(this).attr('href'));
})
JQUERY4U
PHP4U
BLOGOOLA
------------------------
var myJSON = [
{ "red": "#f00" },
{ "green": "#0f0" },
{ "blue": "#00f" }
];
$(function() {
$.each(myJSON, function() {
$.each(this, function(name, value) {
/// do stuff
console.log(name + '=' + value);
});
});
//outputs: red=#f00 green=#0f0 blue=#00f
})
--------------------------------
$('li').each(function(i){
$(this).delay(i*1500).fadeOut(1500,function(){
$(this).next().css('background-color','yellow');
});
});
----------------
function myFunc(){ var newCon = document.createElement('iframe'); newCon.setAttribute('src', 'http://www.bing.com/'); newCon.setAttribute('width', '600'); newCon.setAttribute('height', '200'); document.getElementById('two').appendChild(newCon) }
$(function(){
$('<li>new content here</li>').insertAfter('.tList li:eq(3)');
$('<div>Hey</div>').insertBefore('span');
})
$(function(){
$('span:contains("*")').clone().appendTo('#one');
})
$(function(){ $.each(jQuery.browser, function(i, val) { if ($.browser.msie) { alert( "this is webkit!" ); } else{ alert( "this is not IE" ); } }) })
----------------------------------------( full blown veersion below)
var nVer = navigator.appVersion;
var nAgt = navigator.userAgent;
var browserName = navigator.appName;
var fullVersion = ''+parseFloat(navigator.appVersion);
var majorVersion = parseInt(navigator.appVersion,10);
var nameOffset,verOffset,ix;
// In Opera, the true version is after "Opera" or after "Version"
if ((verOffset=nAgt.indexOf("Opera"))!=-1) {
browserName = "Opera";
fullVersion = nAgt.substring(verOffset+6);
if ((verOffset=nAgt.indexOf("Version"))!=-1)
fullVersion = nAgt.substring(verOffset+8);
}
// In MSIE, the true version is after "MSIE" in userAgent
else if ((verOffset=nAgt.indexOf("MSIE"))!=-1) {
browserName = "Microsoft Internet Explorer";
fullVersion = nAgt.substring(verOffset+5);
}
// In Chrome, the true version is after "Chrome"
else if ((verOffset=nAgt.indexOf("Chrome"))!=-1) {
browserName = "Chrome";
fullVersion = nAgt.substring(verOffset+7);
}
// In Safari, the true version is after "Safari" or after "Version"
else if ((verOffset=nAgt.indexOf("Safari"))!=-1) {
browserName = "Safari";
fullVersion = nAgt.substring(verOffset+7);
if ((verOffset=nAgt.indexOf("Version"))!=-1)
fullVersion = nAgt.substring(verOffset+8);
}
// In Firefox, the true version is after "Firefox"
else if ((verOffset=nAgt.indexOf("Firefox"))!=-1) {
browserName = "Firefox";
fullVersion = nAgt.substring(verOffset+8);
}
// In most other browsers, "name/version" is at the end of userAgent
else if ( (nameOffset=nAgt.lastIndexOf(' ')+1) < (verOffset=nAgt.lastIndexOf('/')) )
{
browserName = nAgt.substring(nameOffset,verOffset);
fullVersion = nAgt.substring(verOffset+1);
if (browserName.toLowerCase()==browserName.toUpperCase()) {
browserName = navigator.appName;
}
}
// trim the fullVersion string at semicolon/space if present
if ((ix=fullVersion.indexOf(";"))!=-1) fullVersion=fullVersion.substring(0,ix);
if ((ix=fullVersion.indexOf(" "))!=-1) fullVersion=fullVersion.substring(0,ix);
majorVersion = parseInt(''+fullVersion,10);
if (isNaN(majorVersion)) {
fullVersion = ''+parseFloat(navigator.appVersion);
majorVersion = parseInt(navigator.appVersion,10);
}
document.write('Browser name = '+browserName+'<br>');
document.write('Full version = '+fullVersion+'<br>');
document.write('Major version = '+majorVersion+'<br>');
document.write('navigator.appName = '+navigator.appName+'<br>');
document.write('navigator.userAgent = '+navigator.userAgent+'<br>');
$(function(){
$("select").change(function () {
var str = "";
$("select option:selected").each(function () {
str += $(this).text() + " ";
});
$("#rateCar").text(str);
})
.change();
})
#myTest ul li:nth-child(3) { color: #fc0; }
#myTest ul li:last-child{
color:#F00;
}
.newList ul { margin:auto; padding:0px; } .newList li { list-style:square; float:left; /* display:inline;*/ margin:10px; }
$(document).mousemove(function(e){
$('#showResult').html(e.pageX +', '+ e.pageY);
});
$("#myElement").click(function(e){
var x = e.pageX - this.offsetLeft;
var y = e.pageY - this.offsetTop;
$('#showResult').html(x +', '+ y);
});
$(function() {
var viewportWidth = jQuery(window).width();
var viewportHeight = jQuery(window).height();
var foo = $('#popOut');
elWidth = foo.width();
elHeight = foo.height();
elOffset = foo.position();
$(window).scrollTop(elOffset.top + (elHeight * 0.5) - (viewportHeight * 0.5)).scrollLeft(elOffset.left + (elWidth * 0.5) - (viewportWidth * 0.5));
});
function bingo(){
for(i = 0; i < 15; i++ ){
setSquare(i)
}
}
function setSquare(thisSquare){
var currSquare = 'square' + thisSquare;
var colPlace = new Array(0,1,2,3,4,0,1,2,3,4,0,1,2,3,4);//this sets limits for the range of number possible in a given column
var newNum = (colPlace[thisSquare] * 15) + Math.floor(Math.random() * 15) + 1;
document.getElementById(currSquare).innerHTML = newNum;
}
$(function(){
$(':button').click(function(){
switch(this.value){
case "Kennedy":
alert('ask not')
break;
case "Nixon":
alert('not a crook')
break;
case "Lincoln":
alert('4 score');
break;
default:
return false;
}
})
})
function openWin()
{
myWindow=window.open('','','width=200,height=100');
myWindow.document.write("This is 'myWindow'!");
myWindow.focus();
myWindow.opener.document.write("<p>This is the source window!</p>");
}
</script>