GB_001 Posted May 27, 2008 Share Posted May 27, 2008 Hello, is it possible to get the value of any onclick event link when clicked, through some sort of system? Link to comment https://forums.phpfreaks.com/topic/107516-getting-value-of-text-when-clicked/ Share on other sites More sharing options...
GB_001 Posted May 28, 2008 Author Share Posted May 28, 2008 For example putting clicked text into a variable. Link to comment https://forums.phpfreaks.com/topic/107516-getting-value-of-text-when-clicked/#findComment-551286 Share on other sites More sharing options...
haku Posted May 28, 2008 Share Posted May 28, 2008 Yes, although how you do it depends on the type of tag that you are doing this on. For example the functions to extract the text from a textarea are different from the function used to extract the text from a div or a p. Link to comment https://forums.phpfreaks.com/topic/107516-getting-value-of-text-when-clicked/#findComment-551292 Share on other sites More sharing options...
rhodesa Posted May 28, 2008 Share Posted May 28, 2008 sounds like you want to use the keyword 'this', which refers to the object be clicked. example: <script type="text/javascript"> function alertText ( text ) { alert(text); } </script> <div id="foobar" onclick="alertText(this.id);">Click Me</div> Link to comment https://forums.phpfreaks.com/topic/107516-getting-value-of-text-when-clicked/#findComment-551601 Share on other sites More sharing options...
GB_001 Posted May 28, 2008 Author Share Posted May 28, 2008 Thankyou! Link to comment https://forums.phpfreaks.com/topic/107516-getting-value-of-text-when-clicked/#findComment-551857 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.