web stats analysis

Java Script Archive

How to pass a Javascript Array via JQuery Post so that all its contents are accessible via the PHP $_POST array?

How to send an array via the url in javascript/jQuery?

If you want to pass a JavaScript object/hash (ie. an associative array in PHP) then you would do:

$.post(‘/url/to/page’, {‘key1′: ‘value’, ‘key2′: ‘value’});

If you wanna pass an actual array (ie. an indexed array in PHP) then you can do:

$.post(‘/url/to/page’, {‘someKeyName’: ['value','value']});

If you want to pass a JavaScript array then you can do:

$.post(‘/url/to/page’, {‘someKeyName’: variableName});

How to use Module Pattern in javascript?

Module Pattern in javascript.

Description of javascript module pattern

Modules are an integral part of any robust application’s architecture and typically help in keeping the units of code for a project both cleanly separated and organized. The module pattern is a common JavaScript coding pattern.If you want to understand Module Pattern you should have knowledge about the Closure principle of JavaScript.

Description about closure:

Closures are define through which inner functions can refer to variables present in their outer enclosing function after their parent functions have already terminated.

Here example for closure:


// Below function generates a new function for adding numbers

function generate(number) {

// Return a simple function for adding two numbers

// with the first number borrowed from the generator

return function (toAdd) {

return number + toAdd
};
}

// addFive now contains a function that takes one argument,

// adds five to it, and returns the resulting number

var five_add = generate(5);

// We can see here that the result of the six_add function is 9,

// when passed an argument of 4

alert(five_add(4) == 9);   // Which return true

Example of Module Pattern


var Module_Employee = (function () {
var List_employee = [];
return {
add: function (employee) {
List_employee.push(employee);
},
getAll: function () {
return List_employee;
},
Count: function () {
return List_employee.length;
}
};
})();
We can use our Module_Employee in below way.

Module_Employee.add({ Id: '01', Name: 'Emon Khan', Designation: 'Software Engineer' });
Module_Employee.add({ Id: '02', Name:'Khairul Islam', Designation: 'Senior Software Engineer'});
Module_Employee.getAll();

How to jQuery Get QueryString Value | Get QueryString Parameter Values in jQuery?

jQuery Get QueryString Value | Get QueryString Parameter Values in jQuery .

Use jQuery Get QueryString Value | Get QueryString Parameter Values in jQuery .

Follow below solution:

Now I explain how to get query string parameter values using jQuery in asp.net?

I explain how to get query string parameter values using
jQuery or get query string variable values using jQuery in asp.net is like below.

Implement below code in youer page.



<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>jQuery & javascript through Get Current Page Url Parameter values</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.js"></script>
<script type="text/javascript">
$(function () {
var u_name = getValues('username');
var id = getValues('userid');
$('#spn_UserName').html('<strong>' + u_name + '</strong>');
$('#spn_UserId').html('<strong>' + id + '</strong>');
});
function getValues(param) {
var url = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
for (var i = 0; i < url.length; i++) {
var urlparam = url[i].split('=');
if (urlparam[0] == param) {
return urlparam[1];
}
}
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<p>UserName: <span id="spn_UserName"></span></p>
<p>UserId: <span id="spn_UserId"></span></p>
</div>
</form>
</body>
</html>

For more deatil Click here.

javascript – How can I get query string values?,javascript – jquery get querystring from URL
how can I get two parameters values from Query string using jquery,
Get Querystring With jQuery.

How to use datepicker in mysite?

datepicker in my site.

Use datepicker in my site.

Add datepicker in my site using jquery.

follow below solution

The datepicker is tied to a standard form input field.
It’s Focus on the input (click, or use the tab key) to open an interactive calendar in a small overlay.
Choose a date, click elsewhere on the page.

If you want to add datepicker in your site,
Then write the following script where you want datepicker in you page.

<script>

$(function()
{

$( "#hopestart" ).datepicker();  // hopestar is a textbox id

$( "#hopelaunch" ).datepicker();  // hopelaunch is a textbox id

});

</script>

How to use datepicker:Using below textbox


<input type="text" id="hopestart" name="hopestart"/>

Click on below image is demo of datepicker.

datepicker in my site,datepicker in wordpress,
use datepicker,use datepicker in wordpress.

How to tab Focus of textbox in ASP.NET using JQuery?

Tab Focus of textbox in ASP.NET using JQuery.

Follow below solution:

When user press the Enter key,
the Tab focus of a textbox moves to the next textbox using JQuery in ASP.NET.

Write below code in the Head tag of a webpage:


<script src="Scripts/jquery-1.9.1.js"
type="text/javascript"></script>
<script type="text/javascript" language="javascript">
$(document).ready(function ()
{
$('input:text:first').focus();
$('input:text').bind('keydown', function (e)
{
if (e.keyCode == 13)
{
e.preventDefault();
var nextIndex = $('input:text').index(this) + 1;
var maxIndex = $('input:text').length;
if (nextIndex < maxIndex)
{
$('input:text:eq(' + nextIndex + ')').focus();
}
}
});
});
</script>

How to create dynamic div tag using javascript?

Creating dynamic div tag using javascript.

I had a simple solution:

Following will create a div dynamiclly

document.createElement(“div”);

It will Removes a child node from the DOM. Returns removed node.

var oldChild = element.removeChild(child);
element.removeChild(child);

Javascript Create New Div HTML Element Dynamically,JS adding dynamic div tag,
Show/Hide HTML div tags using JavaScript,Create Dynamic Div tag.

How to get an input textbox value in variable using JavaScript?

Which code is use to get an input textbox value in variable using JavaScript?

Which way to use get an input textbox value in variable using JavaScript?

Solution is below:

We can get value:
USe document.getElementById().Value;

Syntex


Var name = document.getElementById('textbox ID').value;

How to redirect to another page after click on facebook like button?

How to redirect to another page after click on facebook like button?

Redirect after a user clicked a facebook like button

How to redirect to another page after click on facebook like button?

Write the following script between head tag.


<script type="text/javascript">

window.fbAsyncInit = function () {
FB.init({
appId: 'Your facebook application Id',
status: true,
cookie: true,
xfbml: true,
oauth: true
});
FB.Event.subscribe('edge.create', function (response) {
window.location = "http://code.top10idea.com";
});
};
(function (d) {
var js, id = 'facebook-jssdk';
if (d.getElementById(id)) {
return;
}
js = d.createElement('script');
js.id = id;
js.async = true;
js.src = "//connect.facebook.net/en_US/all.js";
d.getElementsByTagName('head')[0].appendChild(js);
} (document));

</script>

And Write the following code between body tag.



<div id="fb-root">
</div>
<div>

<div data-href="http://www.facebook.com/offerfair" data-width="300px"
data-show-faces="true" data-stream="false" data-header="false">
</div>
</div>

How to show and hide div using javascript ?

Show and hide div using javascript.

How to hide div tag using javascript ?

For Click Here To Download Code.

how to change date format in jquery ui datepicker

Change date format in jQuery UI DatePicker

Find Following Code
$(“#txtDate“).datepicker();
Replace with Following Code
$(‘#txtDate‘).datepicker({ dateFormat: ‘dd-mm-yy’ }).val();
Note :- txtDate is a id of textbox