PDA

View Full Version : how can I do this in javascript


chelvis
01-23-2003, 04:51 PM
I have a framed page called frame.html. This page have two frameset. top and a bottom. On the top portion I am displaying a page with a list of words which have check box next to them (form.html).

On the bottom frame I am displaying a page with a text area(clipboard.html).

If a user click on the check box next to a word, then the word should get copied on the the text area in the bottom frame. Whenever user clicks the check box those words next to it should be copied to the text area.

Is it possible to do this?

frame.html
<HTML>
<TITLE>First Frame Page</TITLE>

<FRAMESET rows="80%,20%">
<FRAME SRC="Thesaurus_terms.html">
<FRAME SRC="clipboard.html">
</FRAMESET>
</HTML>

form.html

<table border="1" width="100%" cellspacing="2" cellpadding="1">
<form name="terms">
<tr><td valign="top" bgcolor="#8294B4"><a CLASS="WhiteText"><b>&nbsp; Term</b></a></td><td valign="top" bgcolor="#8294B4"><a CLASS="WhiteText"><b>No. of Results</b></a></td><td valign="top" bgcolor="#8294B4"><a CLASS="WhiteText"><b>Scopenotes</b></a></td></tr>
<tr><td valign="top"><input type="checkbox" name="1">&nbsp; <a CLASS="LgBLueLink" href="#">Latexes</a></td><td valign="middle"><a CLASS="MedBlackText">9848</a></td><td valign="middle"><img src="images/i.gif" border="0"></td></tr>
<tr><td valign="top"><input type="checkbox" name="1">&nbsp; <a CLASS="LgBlueLink" href="#">Papermaking--Latex applications</a></td><td valign="middle"><a CLASS="MedBlackText">9848</a></td><td valign="middle"><img src="images/i.gif" border="0"></td></tr>
<tr><td valign="top" colspan="3">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a CLASS="MedBlackText"><b>use: </b></a><a CLASS="LgBlueLink" href="#">Latexes</a></td></tr>
<tr><td valign="top"><input type="checkbox" name="1">&nbsp; <a CLASS="LgBlueLink" href="#">Plastics--Latex</a></td><td valign="middle"><a CLASS="MedBlackText">9848</a></td><td valign="middle"><img src="images/i.gif" border="0"></td></tr>
<tr><td valign="top" colspan="3">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a CLASS="MedBlackText"><b>use: </b></a><a CLASS="LgBlueLink" href="#">Latexes</a></td></tr>
<tr><td valign="top"><input type="checkbox" name="1">&nbsp; <a CLASS="LgBlueLink" href="#">Plastics</a></td><td valign="middle"><a CLASS="MedBlackText">9848</a></td><td valign="middle"><img src="images/i.gif" border="0"></td></tr>
<tr><td valign="top"><input type="checkbox" name="1">&nbsp; <a CLASS="LgBlueLink" href="#">Colloids</a></td><td valign="middle"><a CLASS="MedBlackText">9848</a></td><td valign="middle"><img src="images/i.gif" border="0"></td></tr>
<tr><td valign="top"><input type="checkbox" name="1">&nbsp; <a CLASS="LgBlueLink" href="#">Elastomers</a></td><td valign="middle"><a CLASS="MedBlackText">9848</a></td><td valign="middle"><img src="images/i.gif" border="0"></td></tr>
<tr><td valign="top"><input type="checkbox" name="1">&nbsp; <a CLASS="LgBlueLink" href="#">Rubber</a></td><td valign="middle"><a CLASS="MedBlackText">9848</a></td><td valign="middle"><img src="images/i.gif" border="0"></td></tr>
<tr><td valign="top"><input type="checkbox" name="1">&nbsp; <a CLASS="LgBlueLink" href="#">Synthetic rubber</a></td><td valign="middle"><a CLASS="MedBlackText">9848</a></td><td valign="middle"><img src="images/i.gif" border="0"></td></tr>
</form>
</table>

clipboard.html

<html>
<head>
<title>clipboard</title>
</head>

<body>
<form name="clipping">
<input type="textarea" rows="3" cols="24">
</form>
</body>
</html>

Danne
01-23-2003, 05:29 PM
When the user clicks on a word u need an event to take care of it (or use the href-property on the a-tag).




<script>

function copy(word)
{
textArea.value+=word;
}

</script>


<a href="javascript:copy('WORD');">WORD</a>





Since you work between different frames, you need to check the path to the textarea. In IE it would be something like parent.frames[1].textareaID or parent.frames("frameID").textareaID .


And btw, I think you should use <textarea rows="3" cols="24"></textarea>