blackthirteen Posted January 28, 2007 Share Posted January 28, 2007 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 More sharing options...
Lulzim Posted January 28, 2007 Share Posted January 28, 2007 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 More sharing options...
blackthirteen Posted January 29, 2007 Author Share Posted January 29, 2007 thanks!sorry if I posted in the wrong section, I wasn't sure if PHP was responsible of this stuff or not. Link to comment Share on other sites More sharing options...
blackthirteen Posted January 30, 2007 Author Share Posted January 30, 2007 hey, it doesn't work to embed javascript inside php? Example;<?phpecho '<script type="text/javascript">';echo '<br>';echo 'document.write("Hello World!");';echo '</script>';?> Link to comment Share on other sites More sharing options...
justsomeguy Posted January 30, 2007 Share Posted January 30, 2007 Yeah, it works fine. But <br> is an HTML tag, not Javascript. It probably quits when it sees that. Link to comment Share on other sites More sharing options...
Anders Moen Posted January 30, 2007 Share Posted January 30, 2007 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now