Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to call javascript function without button click?

Tags:

javascript

I have seen some pages in which we can input in textarea and correspondingly an output gets displayed for it no button clicks in between , see an example here http://ntools.infoexpo.in/p/html-to-xml-encoder_4042.html

How to apply this type in the below code? html:

<textarea  id="source"  placeholder="Text Entry."></textarea>
<p id="result"> </p>

Javascript

function myFunction()
{
var str = document.getElementById('source').value;

var len = str.length;
    document.getElementById("result").innerHTML="<textarea>"+len+"</textarea>";

}
like image 383
Sreeraj Avatar asked Feb 19 '26 14:02

Sreeraj


1 Answers

If you want to call in on load of your page try this

<body onLoad="yourFunctionName();">
like image 166
MusicLovingIndianGirl Avatar answered Feb 22 '26 02:02

MusicLovingIndianGirl



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!