MDanz Posted September 11, 2009 Share Posted September 11, 2009 like on any forum... how is this done? forms? ajax? i've tried javascript but it only takes the last result in the loop. instead of the message i clicked on. what i'm trying to do is e.g. click on quote button in message 5, then message 5 in quote tags show in the text area. the part i'm having trouble on is passing the information from the button to the textarea without changing page any help... Quote Link to comment https://forums.phpfreaks.com/topic/173908-passing-information-from-button-to-textarea/ Share on other sites More sharing options...
iPixel Posted September 11, 2009 Share Posted September 11, 2009 If you check the way this website works as for qotes... The link Quote to your upper right of the post is a link to itself but it passes a quote ID which is likely the database link if you will to the data of that post. Then simply put the set the value of the textarea to the value of the post that you $_Get[] sent and place the quotes around it. Quote Link to comment https://forums.phpfreaks.com/topic/173908-passing-information-from-button-to-textarea/#findComment-916750 Share on other sites More sharing options...
MDanz Posted September 11, 2009 Author Share Posted September 11, 2009 i have reply.php?id=$id , where id is distinguished by the thread, so all the replies in the thread have e.g. id=44 which is part of the table Threads. and for quotes they have id in the table Reply. how do i add this on to url? i know for reply id its reply.php?id=$id reply.php?id=$id....... what goes after that to distinguish the id of the quote... should be easy after this.. how do i add on a quote id after that? do i use &.. Quote Link to comment https://forums.phpfreaks.com/topic/173908-passing-information-from-button-to-textarea/#findComment-916764 Share on other sites More sharing options...
iPixel Posted September 11, 2009 Share Posted September 11, 2009 reply.php?id=$id"e=ID & lets you push more variables through the url. Quote Link to comment https://forums.phpfreaks.com/topic/173908-passing-information-from-button-to-textarea/#findComment-916772 Share on other sites More sharing options...
MDanz Posted September 11, 2009 Author Share Posted September 11, 2009 how do i use GET to get the quote number? /topic.php?id=44"e=69 Quote Link to comment https://forums.phpfreaks.com/topic/173908-passing-information-from-button-to-textarea/#findComment-916787 Share on other sites More sharing options...
mikesta707 Posted September 11, 2009 Share Posted September 11, 2009 You can do it that way, but that won't be dynamic (IE you will have to reload the page for the quote to actually show up) If i'm not mistaken (and I might be) I believe these forums use javascript to get the quote. The way I would do it is wrap every post in its own unique div tag (IE the div id would be the post number) and use the getElementByID function to get the innerHTML of the div tag and voila. A quick example would look like <script type="text/javascript"> function getText(id){ element = getElementById(id); reply = getElementById("replyBox");//this is the ID of the reply textarea reply.value = "[quote]"+element.innerHTML+"[/quote]"; } </script> and then you would have links like [code] <a href="#quickReply" onclick="getText('post124')">Quote</a> a div may look like <div id="post124"> ZOMG I GET HEDER ERORS HALP </div> You can probably figure out the rest. But this is how I would go about it if i wanted a dynamic quote system like these forums have Quote Link to comment https://forums.phpfreaks.com/topic/173908-passing-information-from-button-to-textarea/#findComment-916828 Share on other sites More sharing options...
iPixel Posted September 11, 2009 Share Posted September 11, 2009 Mikesta707 makes a valid point. That would be a cool way to do it. If you can get each post to be wrapped with a unique ID then you can easily use getElementByID().innerHTML = code-post-here. Good stuff Mike. Quote Link to comment https://forums.phpfreaks.com/topic/173908-passing-information-from-button-to-textarea/#findComment-916857 Share on other sites More sharing options...
MDanz Posted September 11, 2009 Author Share Posted September 11, 2009 i tried but i think i've gone wrong somewhere, the text area isn't filling <div id='$number'><img src='http://www.u-stack.com/quote.jpg' alt='Quote!' onclick='getText('$number')' /> <br><hr size='1'></div> <script type='text/javascript'> function getText(id){ element = getElementById(id); reply = getElementById('reply');//this is the ID of the reply textarea reply.value = '[quote]'+element.innerHTML+'[/quote]'; } </script> <textarea name='reply' cols='50' rows='10' wrap='hard' id='reply'></textarea> where i go wrong? Quote Link to comment https://forums.phpfreaks.com/topic/173908-passing-information-from-button-to-textarea/#findComment-916891 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.