pcw Posted June 24, 2009 Share Posted June 24, 2009 Hi, I have a textarea that is populated with some code. I would like to be able to select that code with the click of a button. It would be cool if this was copied at the same time, so it could be pasted into another document. I have seen similar with javascript, but am not comfortable with using it, and prefer PHP. Any help is much appreciated. Thanks Link to comment https://forums.phpfreaks.com/topic/163516-php-select-all-in-textarea/ Share on other sites More sharing options...
PFMaBiSmAd Posted June 24, 2009 Share Posted June 24, 2009 Php is a server side scripting language. It is executed on the web server when the page it requested. It outputs content (HTML/CSS/Javascript/media) to the browser. A textarea only really exists after it has been rendered by the browser. You will need to use a client-side solution (javascript.) Link to comment https://forums.phpfreaks.com/topic/163516-php-select-all-in-textarea/#findComment-862750 Share on other sites More sharing options...
947740 Posted June 24, 2009 Share Posted June 24, 2009 PFMaBiSmAd is right. But here ya go. <a href='#' onclick='document.formname.textareaname.select()'>Select Text</a> <form name='formname'> <textarea name='textareaname'></textarea> If you are not comfortable with adding an onclick property to a link... Link to comment https://forums.phpfreaks.com/topic/163516-php-select-all-in-textarea/#findComment-862767 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.