phpinfo() Posted March 6, 2008 Share Posted March 6, 2008 I have a php function that is getting and displaying a list of text. - I am trying to make it so each text item displayed will also be a link. (The link will be a javascript link to put the specific line of text into a form field) <script> function inserttexttoformfield() { var newtext = '<?php echo htmlentities($variable) ?>' + ','; document.f1.outputtext.value += newtext; } </script> <a href="javascript:inserttexttoformfield();"><?php echo htmlentities($variable) ?></a> This works, but if you have a list of 10 items, each has the same link as whatever the last item was. For example, if you have a list displaying numbers 1-10, each number will have a link for 10 to post to the form. How can I have a "running" link for each item? Would I post the php variable + another character that I call to? Quote Link to comment Share on other sites More sharing options...
phpinfo() Posted March 6, 2008 Author Share Posted March 6, 2008 Wanted to specify that the links will be posting the text in the same text field. They will be separated by commas, which is in the javascript code above. - Basically once the full list of text comes up, I want to be able to browse through and select a few by clicking on them via a link, radio, checkbox etc. and have them sent to a text field being separated by a comma. Quote Link to comment Share on other sites More sharing options...
mainewoods Posted March 6, 2008 Share Posted March 6, 2008 <script> function inserttexttoformfield(thetext) { //parameter passed var newtext = thetext + ','; document.f1.outputtext.value += newtext; } </script> -each link has a parameter to the javascript function that is written server side. That parameter will be passed to the javascript function when the link is clicked. <a href="javascript:inserttexttoformfield('<?php echo addslashes($variable) ?>');"><?php echo htmlentities($variable) ?></a> Quote Link to comment 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.