Syntax string .substr(start,length) Parameter Description start Required. The index where to start the extraction. First character is at index 0 length Optional. The number of characters to extract. If omitted, it extracts the rest of the string
Example
Example
Extract characters from …
how to get xmldoc in a string
•
Tapovan
put this line wherever u needed to do this.
var string = (new XMLSerializer()).serializeToString(xmlDoc);
how to load a string into dom
•
Tapovan
//------------- load a string into dom --------
//@param: string to be loaded
//@return: xml dom document
function dom_load(string)
{ //alert("dom_load"); if (window.DOMParser)
{
parser=new DOMParser();
xmlDoc=parser.parseFromString(string,"text/xml");
…
angle between two points in javascript
•
Tapovan
//--------- to get angle between two points ---------
//---param---
//@x1,x2,y1,y2 : cordinates of 2 points
//@return: theta(value in degrees)
function getTanTheta(x1,y1,x2,y2)
{ var y = eval(y2)-eval(y1); var x = eval(x2)-eval(x1); if(y < 0) { y = -y;} if(x < 0) { x = -x;} //…
Round number in javascript
•
Tapovan
//------- Rounding in javascript --------
//@param: Number, length to round
//@return: Rounded number
function roundNumber(rnum, rlength)
{ // Arguments: number to round, number of decimal places var newnumber = Math.round(rnum*Math.pow(10,rlength))/Math.pow(10,rlength); newNumb…
Fetching an URL :
•
Tapovan
Just make a variable as given below and that's it.
$our_url ='http'.((!empty($_SERVER['HTTPS']))?'s':'').'://'.$_SERVER['SERVER_NAME'].$_SERVER['PHP_SELF'];
Dropdown Reset Javascript
•
Tapovan
To reset dropdown/ or selectbox, we can simply fire this javascript code on any dom event
document.getElementById("id_of_selectbox").selectedIndex = -1;
The selectedIndex method of javascript will reset the index of the selected dropbox.
Another and better optio…
an "open and free" initiative. Powered by Blogger.