I want to when entering in textarea imediately show me the submit button I can use
<input type="submit" id="submit" name='sub' value="Transfer" style="visibility: hidden" />
is there any solution with php or javascript?
Brettz SOLUTION:
<html>
<head></head>
<form>
<input type="submit" id="submit" name='sub' value="Transfer" style="visibility: hidden" />
<textarea id="mytextarea"></textarea>
<script type="text/javascript">
function addEvent (el, type, listener) {
if (el.addEventListener) {
el.addEventListener(type, listener, false);
}
else if (el.attachEvent) {
el.attachEvent('on'+type, listener);
}
else {
el['on'+type] = listener;
}
}
addEvent(document.getElementById('mytextarea'), 'input', function () {
document.getElementById('submit').style.visibility = 'visible';
});
</script>
</form>
</html>
Notice I’ve added a textarea with the id “mytextarea”:
…which you can of course change to your own name or needs.
amolv’s solution is convenient for quick-and-dirty building of a page. But inline JavaScript (and inline formatting or CSS) is generally frowned upon for real applications, as it is cleaner for the structure of your page (the HTML) to be separated from the behaviors (typically JavaScript, though HTML5 is adding a
<command/>element which could let you separate the behaviors in a special part of your HTML).Moving the scripts (and styles) to a separate page, also lets a browser cache (remember) the scripts without needing to reload it when the user visits another page at your site which might reuse the same code. Your server will therefore only need to deliver raw HTML (after the first download) without all the script text mixed inside, thereby speeding up delivery of your page content to the user.