Page 1 of 1

Flashing a link to a text field - HOW!?

Posted: Thu Jan 29, 2004 5:32 pm
by kanshou
Well, here's what I want to do, maybe you can tell me how to do it..
I want to have a list of items, that are clickable links, ie. apple, tomato, pear, carrot. Whenever you click on one of those links, it adds it to a nearby text field. Much like how the PHP block buttons work in this topic entry.

Thanks!!!!

Posted: Thu Jan 29, 2004 5:33 pm
by DuFF
Unless you want refresh the page you'll have to use Javascript. PHP is server-side only. Javascript is client side.

Posted: Thu Jan 29, 2004 5:56 pm
by kanshou
using javascript is fine, so long as I can send it to mysql

Posted: Fri Jan 30, 2004 1:44 pm
by Unipus
the simplest way is probably something like this:

Code: Select all

<script>
function addToText(product)
&#123;
      var text = document.GetElementbyId('textfield');
      text.value = text.value + product;
&#125;

<a href="garbage" onclick="addToText('carrot'); return false">carrot</a>

<textarea id="textfield" name="textfield"></textarea>
Just off the top of my head. There's plenty of ways to refine that to make it more extensible, but it should work.