Jump to content

Run Javascript function on a form


footiefan

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...