Jump to content

Instant text with clickable buttons


blackthirteen

Recommended Posts

How can I make a clickable button that instantly adds text in the text area?Let’s suppose I just want to create a button that write “hello world” straight away in the text area during a form, how do I do it the simplest way? What do I need to know?Anyone could write a small working code so I can have a good idea of the basic thing?

Link to comment
Share on other sites

you can do that with javascripthere is an example:

<html><head>	<script type='text/javascript'>	function instantText (text)	{		document.getElementById("txt").value=text;	}	</script></head><body>	<textarea name='txt' id='txt'>	</textarea><br />		<input type='button' name='button1' value='instant text' onclick='instantText("Hello world");' /></body></html>

Link to comment
Share on other sites

Yeah, it works fine. But <br> is an HTML tag, not Javascript. It probably quits when it sees that.
Yeah. Correct, but not if he uses this:<?phpecho '<script type="text/javascript">';echo 'document.write("<br>")';echo 'document.write("Hello World!");';echo '</script>';?>
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...