Jump to content

Run Javascript function on a form


footiefan
 Share

Recommended Posts

Hi everyone, I admit I'm poor on Javascript.I have an asp page, this shows some stats taken out from a database.I wish users to be able to pick up some of them and paste them into a forum for discussion.So I made a form, in which the relevant data appears.Now I wish them to be able to copy those data to the clipboard so it's easy to correctly post them on a phpbb forum (I've inserted there all the tags too).I have the function I need, but cannot understand how to lauch the function.May someone have a look and tell me where's the error?Thanks!P.S. The first code window is what I have on top of the page, together with other javascript functions.The second is the text area at the bottom of the page.

function copyToClipboard('playervaluesarea') {   window.prompt ("Copy to clipboard: Ctrl+C, Enter", playervaluesarea); }

<FORM name="playervalues" METHOD="post"> <textarea name="playervaluesarea" rows="1" cols="60">[col]xxxx: |<%=PName&"-View"%>[/col] [col]yyyyy: |<%=Puuuu%>[/col] [col]zzzzz: |<%=Pzzzz%>[/col] </textarea> <input type="button" value="Copy" onClick="CopytoClipboard('playervaluesarea');"> </form>

Link to comment
Share on other sites

function CopyToclipboard(){elemValue=document.getElementById('playerValuesarea').value; prompt(copy...ctrl+c enter:",elemValue)}

CALL IT:

<input onclick="CopyToClipboard()".../>

EDIT: make sure your change you <textarea> name to id. E.G:

<textarea id="playerValuesarea">

Edited by O. Samuel
Link to comment
Share on other sites

function CopyToclipboard(){elemValue=document.getElementById('playerValuesarea').value; prompt(copy...ctrl+c enter:",elemValue)}

CALL IT:

<input onclick="CopyToClipboard()".../>

EDIT: make sure your change you <textarea> name to id. E.G:

<textarea id="playerValuesarea">

It works fine!Thanks a lot!!! :)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...