How to Get the whole query string text from address bar

In PHP you can get the query string text with is separated by URL via '?' character. For this you can use 'query_string' with server variable.

So you can use it like


echo $_SERVER['QUERY_STRING'];
?>

So, for following URL in address bar:-
www.mobifonz.com?var1=3&var3=this

Output will be:-
var1=3&var3=this

And for following URL in address bar:-
www.mobifonz.com?this_Is_Some_Text

Output will be:-
this_Is_Some_Text

Means it will return anything after the '?' sign.

Posted in |

HTML tag to display the html code on webpage

Paste "html code to be shown" here.

Posted in |

Highlight Text Inside Div

function selectText(divID) //divID contains actual id of 'div' element
{
var textC=document.getElementById(divID);
if (document.selection)
{
//Portion for IE
var div = document.body.createTextRange();
div.moveToElementText(textC);
div.select();
}
else
{
//Portion for FF
var div = document.createRange();
div.setStartBefore(textC);
div.setEndAfter(textC);
window.getSelection().addRange(div);
alert(div.value);
}
}

Posted in |

javascript to partial text in a div element

Some times we need mechanisms to select(highlight) partial text in a div or td element, lets say on click of a button. So that visitor just right click on selected text and copy the text to paste it anywhere else.

The code I am going to publish selects the div elements on the base of starting character and length of div text.

Lets say if you want to select first 500 characters in div you will provide the "start" argument as 0 and length as 500.

Similarly, you can choose to select(highlight) the text form 100th character to 600th in the div. In this case you will provide the "start" as 100 and "length" as 600. First argument will be id of div element in which text is to be select.

Lets go to the actual code now. here goes the select text function.

function selectText(ID, start, length)
{

if (document.selection)
{
//Code for IE and few other
document.selection.empty();
var textC = document.getElementById(ID);
var div = document.body.createTextRange();
div.moveToElementText(textC);
div.setEndPoint("EndToEnd", div);
div.moveStart('character', start);
if(length + start>textC.innerHTML.length)
length=textC.innerHTML.length-start;

div.moveEnd('character', -(textC.innerHTML.length - start - length));
div.select();
}
else
{
//code for FF and few other
window.getSelection().removeAllRanges();
var textC = document.getElementById(ID);
while ( textC.hasChildNodes() ) textC = textC.childNodes[0];
var div = document.createRange();

div.setStart(textC, start);
if (start+length > textC.length) length = textC.length - start;
div.setEnd(textC, start+length);

window.getSelection().addRange(div);
}

return false;

}

Now this is how we will implement this in HTML for lets say selecting first 500 characters in this case.


Some text here to be selected...

Posted in |

get visitors IP

Posted in |

easy code from Coldfusion send email with attachment


from="sendersaddress@anysite.com"
subject="my first email with attachment"
type="text"
mimeattach="subfolder/folder/mypdf.pdf"> (path of file, which is to be attached)

hi,
This is me sending you attached file.

Bye,
sender

Posted in |

PHP Get the whole query string text from address bar


Previously in a comment a question was asked from me about how to get the text following the URL in title bar.

In PHP you can get the query string text with is separated by URL via '?' character. For this you can use 'query_string' with server variable.

So you can use it like


echo $_SERVER['QUERY_STRING'];
?>

So, for following URL in address bar:-
www.mobifonz.com?var1=3&var3=this

Output will be:-
var1=3&var3=this

And for following URL in address bar:-
www.mobifonz.com?this_Is_Some_Text

Output will be:-
this_Is_Some_Text

Means it will return anything after the '?' sign.

Posted in |

display the html code on webpage


The easiest way to show the HTML code on a web page is to use XMP tag. Normally html code is always executed and we can show it using the values of '<' and '>' like &lt_; and &gt_; without the underscores.

But XMP tag method is more convinient. The html code you want to show on a webpage just surround it with XMP code and thats it.

Paste "html code to be shown" here.

Enjoy! Your comments are always welcome.

Posted in |

Coldfusion get visitors IP


Here is how you can get the visitor's IP in Coldfusion.

#CGI.REMOTE_ADDR#

OR just set a variable with IP like


Enjoy!!

Posted in |

Coldfusion send text email


Sending email is quite a basic feature now a days which every website need to do. I have done this in PHP as well but I don't think so that there is any other language other than coldfusion which have email sending code smaller than cold fusion. Additionally I will not say it code :-). Its more like piece of a cake. Anyways the code to send email in coldfusion follows as,


to="email@site.com"
cc="address2@site.com"
bcc="anyaddress@site.com"
from="sender@site.com"
subject="Check this out" type="text">
Dear Friend,

I have searched out a good website which says it all about coding.
I would like you to check it out.

Site is: http://codingtricks.blogspot.com

Regard,
Mail Sender :-)


Posted in |

Coldfusion send email with attachment files


Sending attachment emails are also as easy as sending the text email messages. Just addition you have to do to normal Coldfusion email is that you have to specify the path of file to be attached and you are done. So following is the code to send attachment Email in coldfusion


from="sendersaddress@anysite.com"
subject="my first email with attachment"
type="text"
mimeattach="subfolder/folder/mypdf.pdf"> (path of file, which is to be attached)

hi,
This is me sending you attached file.

Bye,
sender

Posted in |