Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
Insert anchor text of link into text box
Old 11-05-2006, 08:39 PM Insert anchor text of link into text box
Yak Yak Yak Yak Yak

Posts: 593
Location: Rochester, MN
Trades: 0
Does anyone know a way to do this?

Lets say we have a page that has the following information:
<content>
Clean Dirty Widgets Blue Green Red

< blank text box >
</content>

I would like to make the individual words "clickable", so when you click the word, it places that work inside the text box. Then, if you click another word, it places that word in the text box AFTER the first word. Basically, if you click the words in any order, it will record the order they were clicked in the text box.

If I click Dirty, then Red, then Widgets; it would show the following in the text box:

Dirty Red Widgets

Is that possible? I am guessing this would be done in javascript, but I am not certain. Can someone point me in the right direction?

Thank you.

Frank
__________________

Please login or register to view this content. Registration is FREE
neorunner is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 11-06-2006, 04:00 AM Re: Insert anchor text of link into text box
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,519
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
At the simplest;
each word would need to be a seperate entity in a span with an ID, then with an onClick routine assigned to the element you could do something like;

HTML Code:
function copyToTextBox(eleID) {
     strText = document.getElementByID(eleID).innerHTML; 
     document.getElementByID("textboxName").value = document.getElementByID("textboxName").value + ' ' +strText;
}
use onClick="copyToTextBox(this.ID)" to call


not tested the code at all.
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 11-06-2006, 04:03 AM Re: Insert anchor text of link into text box
Novice Talker

Posts: 9
Location: Russian Federation
Trades: 0
Maybe something, like that:
Code:
 
function F(e) {
  var r, w;
  if(document.selection) {
    (r = document.body.createTextRange())
      .moveToPoint(e.clientX, e.clientY);
    r.expand('word');
    w = r.text;
  }
  else if(document.createRange) {
    (r = document.createRange())
      .setStart(e.rangeParent, e.rangeOffset);
    r.setEnd(e.rangeParent, e.rangeOffset);
    window.expandRangeToWord(r);
    w = r.toString();
  }
  return w;
}
Code:
 
<p onclick="document.getElementById('test').value += ' ' + (F(event) || '')">
  Clean Dirty Widgets Blue Green Red
</p>
<textarea id='test' cols='20' rows='10'></textarea>
_ru_ is offline
Reply With Quote
View Public Profile
 
Old 11-09-2006, 03:36 AM Re: Insert anchor text of link into text box
seomumbai's Avatar
Skilled Talker

Posts: 98
Trades: 0
i think this would be more easy if u do that in server side.
seomumbai is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Insert anchor text of link into text box
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.40752 seconds with 12 queries