点击图片,在文本框中插入文字:怎么样? [英] Click on a picture, insert text in a text box: how?

查看:48
本文介绍了点击图片,在文本框中插入文字:怎么样?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在努力使网页执行以下操作:


我希望用户能够点击给定的图像(将会有超过

一张图片)。单击给定图像后,特定于该图像的字符将被插入到文本框中,该文本框实际上是文本区域。如果

光标位于textbox / textarea中,则字符将插入光标位置

。这意味着如果光标位于某些文本之间,那么

字符需要插入到光标

所在的文本之间。如果光标不在textbox / textarea中,则字符需要

显示在任何文本的结尾或开头如果没有文本

存在。请记住,要插入的字符对于给定图像的

是唯一的。页面上只有一个textbox / textarea我想要这样做。$ / b

我对Javascript有点了解但是远远不够来自专家。我找到了一个网页

来做这件事并从中复制代码。但是不能让它正常工作。

事实上我收到了一个java错误。不知道为什么。有没有人

有一个方便的链接我可以去看一个简单的例子,在网页上没有大量的东西,所以我可以轻松提取代码?当我保存源文件时,我发现的

网页非常庞大而且很难从它中选择代码来获取代码,尽管我认为我正确得到了它所有。或者,或许

有人可以在回复此消息时发布代码,并以一些

短HTML为例?谢谢!


Chris Smith

I''m trying to make a webpage do the following:

I want a user to be able to click on a given image (there will be more than
one image). Upon clicking a given image, characters specific to that image
will be inserted into a textbox which is actually a text area. If the
cursor is in the textbox/textarea then the characters are to be inserted at
the cursor location. This means if the cursor is between some text then the
characters need to be inserted in between the text exactly where the cursor
is. If the cursor is not in the textbox/textarea then the characters need
to be displayed at the end of any text or at the start if there is no text
present. Keep in mind the characters to be inserted will be unique to a
given image. There will be only one textbox/textarea on the pages I''m
wanting to do this on.

I know a bit about Javascript but am far from an expert. I found a webpage
that does this and copied the code from it. Can''t get it working though.
I''m getting a java error as a matter of fact. No idea why. Does anyone
have a link handy I can go to see a simple example of this without a large
amount of stuff on the webpage so I can easily extract the code? The
webpage I found, when I save the source file, is huge and it''s hard to pick
the code out of it although I thought I correctly got it all. Or, perhaps
someone can post the code in a response to this message aloing with some
short HTML as an example? Thanks!

Chris Smith

推荐答案

2004年8月9日星期一22:07:51 -0400谁是dat?写道:
On Mon, 9 Aug 2004 22:07:51 -0400, who be dat? wrote:
事实上,我收到一个java错误。
I''m getting a java error as a matter of fact.




如果是Javascript,你应该得到

a Javascript错误,因为它发生。他们是

不同的语言..


-

Andrew Thompson
http://www.PhySci.org/ 开源软件套件
http://www.PhySci.org/codes/ Web& IT帮助
http://www.1point1C.org/ Science&技术



If it is Javascript, you should be getting
a Javascript error as it happens. They are
different languages..

--
Andrew Thompson
http://www.PhySci.org/ Open-source software suite
http://www.PhySci.org/codes/ Web & IT Help
http://www.1point1C.org/ Science & Technology


是的,它是Javascript。据我所知,这是在代码

中正确陈述的。当我说Java时,这是我的新闻帖中的一个错误。任何想法

对某些代码会这样做吗?谢谢!


Chris Smith


" Andrew Thompson" <硒******** @ www.invalid>在留言中写道

新闻:k8 ***************************** @ 40tude.net ...
Yeah, it''s Javascript. As far as I know, it''s stated such in the code
correctly. When I said Java, that was a mistake in my newspost. Any ideas
on some code that will do this? Thanks!

Chris Smith

"Andrew Thompson" <Se********@www.invalid> wrote in message
news:k8*****************************@40tude.net...
2004年8月9日星期一22:07:51 -0400,谁是dat?写道:
On Mon, 9 Aug 2004 22:07:51 -0400, who be dat? wrote:
事实上,我收到一个java错误。
I''m getting a java error as a matter of fact.



如果是Javascript,你应该得到<发生Javascript错误。他们是不同的语言..

-
Andrew Thompson
http://www.PhySci.org/ 开源软件套件
http://www.PhySci.org/codes/ Web& IT帮助
http://www.1point1C.org/ Science&技术



If it is Javascript, you should be getting
a Javascript error as it happens. They are
different languages..

--
Andrew Thompson
http://www.PhySci.org/ Open-source software suite
http://www.PhySci.org/codes/ Web & IT Help
http://www.1point1C.org/ Science & Technology



2004年8月10日星期二07:24:17 -0400,谁是dat?写道:
On Tue, 10 Aug 2004 07:24:17 -0400, who be dat? wrote:
是的,它是Javascript。据我所知,正确地在代码中说明了这一点。当我说Java时,这是我的新闻帖中的一个错误。对于某些代码会有什么想法吗?
Yeah, it''s Javascript. As far as I know, it''s stated such in the code
correctly. When I said Java, that was a mistake in my newspost. Any ideas
on some code that will do this?




(笑)这是一个错字?对不起,只是想要

来检查我们都在同一页面上..


我会留下聪明而博学的回答
$对于JS大师来说是b $ b ..(不,我不是*其中之一,

我只是一个潜伏的Java程序员/网页设计师

这里获得上述提示。)


-

Andrew Thompson
http://www.PhySci.org/ 开源软件套件
http://www.PhySci.org/codes/ Web& IT帮助
http://www.1point1C.org/ Science&技术



(chuckles) It was a typo? Sorry, just wanted
to check we were all on the same page..

I''ll leave the intelligent and erudite responses
for the JS gurus.. (No, I am *not* one of them,
I am a mere Java programmer/web designer who lurks
here to gain tips from the aforementioned.)

--
Andrew Thompson
http://www.PhySci.org/ Open-source software suite
http://www.PhySci.org/codes/ Web & IT Help
http://www.1point1C.org/ Science & Technology


这篇关于点击图片,在文本框中插入文字:怎么样?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆