Flashing a link to a text field - HOW!?

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
kanshou
Forum Commoner
Posts: 47
Joined: Sun Aug 03, 2003 1:57 pm
Location: San Diego
Contact:

Flashing a link to a text field - HOW!?

Post 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!!!!
User avatar
DuFF
Forum Contributor
Posts: 495
Joined: Tue Jun 24, 2003 7:49 pm
Location: USA

Post by DuFF »

Unless you want refresh the page you'll have to use Javascript. PHP is server-side only. Javascript is client side.
User avatar
kanshou
Forum Commoner
Posts: 47
Joined: Sun Aug 03, 2003 1:57 pm
Location: San Diego
Contact:

Post by kanshou »

using javascript is fine, so long as I can send it to mysql
Unipus
Forum Contributor
Posts: 409
Joined: Tue Aug 26, 2003 2:06 pm
Location: Los Angeles, CA

Post 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.
Post Reply