Jump to content

PHP Javascript Series Link???


phpinfo()

Recommended Posts

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

<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>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.