从下拉列表填充文本框 [英] populate text box from dropdown

查看:74
本文介绍了从下拉列表填充文本框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望这是一个简单的请求。我不能用javascript编写代码,但我非常擅长用

略微修改来进行cusomizing。我在ASP和HTML中编码。


我试图捕获客户对产品名称的输入以放置我们制作的自定义标签。有些标签上有我们的

产品名称,但客户可以添加我们不卖的其他产品。


所以,我的产品详细信息页面我想要一个文本框,可以从下拉框中的值复制行(包含700
产品ID和名称)。这样我就可以将值从文本框传递到我的ASP脚本,以便处理到

数据库。


这就是我看到的样子:


左下角,''COPY''按钮位于中间,文本框位于右侧。


所以你要在下拉列表中选择一个产品,点击按钮,该产品将附加到文本框,

在其他项目之前或之后。然后客户会在下拉列表中选择另一个产品,然后点击按钮将其附加到列表中等等。


客户也将被允许输入文本框中的其他项目。


这可以吗?从我粗略的网页搜索阅读中,我看到Netscape不允许复制到剪贴板。我不认为
认为剪贴板是必需的,因为源和目标控件在同一个网页上,所以我相信

javascript可以处理所有这些。


非常感谢任何回复。


Daniel Dillon

解决方案

" Dannyboyo" <哒****** @ gto.net>写道:

这就是我看的样子:

左下角,''COPY''按钮位于中间,右边是Textbox。

因此,您可以在下拉列表中选择一个产品,点击该按钮,然后将该产品附加到文本框中,或者在其他项目之前或之后



试试这个:

---

< script type =" text / javascript">

函数copy(){

var sel = document.getElementById(" names");

var text = sel.options.value;

var out = document.getElementById(" output");

out.value + = text +" \ n" ;;

}

< / script>


< select id =" names">

< option> Product一个< / option>

<选项>产品二< /选项>

<选项>产品三< /选项>

&l t;选项>产品四< /选项>

< / select>

< input type =" button"的onclick = QUOT;复印()" value =" Copy">

< textarea id =" output">< / textarea>

---

如果你需要它在旧版浏览器中工作,例如Netscape 4,你需要

更多的Javascript来处理它。


/ L

-

Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML死亡颜色:< URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>

''没有判断的信仰只会降低精神神圣。''




" Lasse Reichstein Nielsen" < lr*@hotpop.com>在消息中写道

news:65 ********** @ hotpop.com ...

" Dannyboyo" <哒****** @ gto.net>写道:

这就是我看的样子:

左下角,''COPY''按钮位于中间,文本框位于
右侧。
所以你要在下拉列表中选择一个产品,点击按钮,然后
该产品将附加到文本框中,或者在其他项目之前或之后


我正在努力完成类似的事情。

我想从下拉列表中选择选项,以及在文本中输入文字

字段,并在按下提交按钮后,将文本和选项

复制到另一个较大的文本区域框中。


示例/建议以下似乎对我不起作用。


因为我的脚本编写非常简陋,也许如果有人会这样做,那么就像提供一个完整的工作示例,其中包含一个下拉列表和一个将被复制到另一个tex中的文本字段t区域,我可以修改和

建立在那个。


任何和所有帮助赞赏。


尝试这个:
---
< script type =" text / javascript">
function copy(){
var sel = document.getElementById(" names" );
var text = sel.options.value;
var out = document.getElementById(" output");
out.value + = text +" \\\
" ;;
}
< / script>
< select id =" names">
< option> Product One< / option>
< option> Product Two< / option>
< option> Product 3< / option>
< option> Product Four< / option>
< / select>
< input type =" button"的onclick = QUOT;复印()" value =" Copy">
< textarea id =" output">< / textarea>
---

如果您需要它可以在较老的浏览器,例如Netscape 4,你需要更多的Javascript来处理它。

/ L
-
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML死亡颜色:
< URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html> ; 没有判断的信仰只会降低精神神圣。



我认为这句话的内容是:

var text = sel.options.value;


应为:

var text = sel.options [sel.selectedIndex] .value;


问候,

Chris。

" Desperado" <德************* @ hotmail.net>在消息中写道

新闻:ee ****************************** @ news.teranew s。 com ...


Lasse Reichstein Nielsen < lr*@hotpop.com>在消息中写道
新闻:65 ********** @ hotpop.com ...

" Dannyboyo" <哒****** @ gto.net>写道:

这就是我看的样子:

左下角,''COPY''按钮位于中间,Textbox on

右。
所以你要在下拉列表中选择一个产品,点击按钮,然后
该产品将附加到文本框中,或者在其他项目之前或之后



我正在努力完成类似的事情。
我想从下拉列表中选择选项,以及在

中输入文字

文本字段,并在按下提交按钮后,将文本和选项复制到另一个较大的文本区域框中。

下面的示例/建议不是''似乎对我有用。

由于我的脚本编写非常简陋,或许如果有人能够提供一个完整的,有效的示例,只需一个下拉菜单和
一个文本字段,将被复制到另一个te xt区域,我可以修改并在此基础上构建。

任何和所有帮助都赞赏。


尝试这个:
---
< script type =" text / javascript">
function copy(){
var sel = document.getElementById(" names" );
var text = sel.options.value;
var out = document.getElementById(" output");
out.value + = text +" \\\
" ;;
}
< / script>
< select id =" names">
< option> Product One< / option>
< option> Product Two< / option>
< option> Product 3< / option>
< option> Product Four< / option>
< / select>
< input type =" button"的onclick = QUOT;复印()" value =" Copy">
< textarea id =" output">< / textarea>
---

如果您需要它可以在较老的浏览器,例如Netscape 4,你需要更多的Javascript来处理它。

/ L
-
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML死亡色彩:


< URL:http://www.infimum.dk/HTML /rasterTriangleDOM.html>

''没有判断的信仰只会降低精神神圣。''




I have what I hope is a simple request. I can''t really code in javascript, but I am pretty good at cusomizing it with
slight modifications. I code in ASP and HTML.

I am trying to capture customer input of product names to put on custom labels we make. Some of the labels will have our
product names on them, but the customer can add other products that we do not sell.

So, on my product detail page I want a textbox that can have rows copied from values in a dropdown box (containing 700
product ids and names). This is so I can pass the values from the textbox to my ASP script for processing into the
database.

This is how I see it looking:

Dropdown on left, ''COPY'' button in middle, Textbox on right.

So you would select a product in the dropdown, click the button and that product would be APPENDED to the textbox,
either before or after the other items already in it. Then the customer would choose another product in the dropdown and
click the button to append it to the list, etc.

The customer will also be allowed to type in other items in the textbox.

Is this do-able? From my sketchy web-search reading, I see that Netscape does not allow copying to clipboard. I don''t
think the clipboard would be required, since the source and destination controls are on the same web page, so I believe
javascript can handle it all.

Any responses are greatly appreciated.

Daniel Dillon

解决方案

"Dannyboyo" <da******@gto.net> writes:

This is how I see it looking:

Dropdown on left, ''COPY'' button in middle, Textbox on right.

So you would select a product in the dropdown, click the button and
that product would be APPENDED to the textbox, either before or
after the other items already in it.



Try this:
---
<script type="text/javascript">
function copy() {
var sel = document.getElementById("names");
var text = sel.options.value;
var out = document.getElementById("output");
out.value += text+"\n";
}
</script>

<select id="names">
<option>Product One</option>
<option>Product Two</option>
<option>Product Three</option>
<option>Product Four</option>
</select>
<input type="button" onclick="copy()" value="Copy">
<textarea id="output"></textarea>
---

If you need it to work in older browsers, e.g., Netscape 4, you need
more Javascript to handle it.

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
''Faith without judgement merely degrades the spirit divine.''



"Lasse Reichstein Nielsen" <lr*@hotpop.com> wrote in message
news:65**********@hotpop.com...

"Dannyboyo" <da******@gto.net> writes:

This is how I see it looking:

Dropdown on left, ''COPY'' button in middle, Textbox on right.
So you would select a product in the dropdown, click the button and
that product would be APPENDED to the textbox, either before or
after the other items already in it.


I am trying to accomplish something similar to this.
I would like to select options from dropdowns, as well as enter text in text
fields, and upon pressing the submit button, have the text and selections
copied into another, larger, text area box.

The example/suggestion ofered below doesn''t seem to work for me.

Since my scripting skils are very rudimentary, perhaps if someone would be
so kind as to provide a complete, working example with one dropdown and one
text field that would be copied into another text area, I could modify and
build upon that.

Any and all help appreciated.


Try this:
---
<script type="text/javascript">
function copy() {
var sel = document.getElementById("names");
var text = sel.options.value;
var out = document.getElementById("output");
out.value += text+"\n";
}
</script>

<select id="names">
<option>Product One</option>
<option>Product Two</option>
<option>Product Three</option>
<option>Product Four</option>
</select>
<input type="button" onclick="copy()" value="Copy">
<textarea id="output"></textarea>
---

If you need it to work in older browsers, e.g., Netscape 4, you need
more Javascript to handle it.

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html> ''Faith without judgement merely degrades the spirit divine.''



I think the line that reads:

var text = sel.options.value;
should read:
var text = sel.options[sel.selectedIndex].value;

Regards,
Chris.
"Desperado" <de*************@hotmail.net> wrote in message
news:ee******************************@news.teranew s.com...


"Lasse Reichstein Nielsen" <lr*@hotpop.com> wrote in message
news:65**********@hotpop.com...

"Dannyboyo" <da******@gto.net> writes:

This is how I see it looking:

Dropdown on left, ''COPY'' button in middle, Textbox on

right.
So you would select a product in the dropdown, click the button and
that product would be APPENDED to the textbox, either before or
after the other items already in it.



I am trying to accomplish something similar to this.
I would like to select options from dropdowns, as well as enter text in


text fields, and upon pressing the submit button, have the text and selections
copied into another, larger, text area box.

The example/suggestion ofered below doesn''t seem to work for me.

Since my scripting skils are very rudimentary, perhaps if someone would be
so kind as to provide a complete, working example with one dropdown and one text field that would be copied into another text area, I could modify and
build upon that.

Any and all help appreciated.


Try this:
---
<script type="text/javascript">
function copy() {
var sel = document.getElementById("names");
var text = sel.options.value;
var out = document.getElementById("output");
out.value += text+"\n";
}
</script>

<select id="names">
<option>Product One</option>
<option>Product Two</option>
<option>Product Three</option>
<option>Product Four</option>
</select>
<input type="button" onclick="copy()" value="Copy">
<textarea id="output"></textarea>
---

If you need it to work in older browsers, e.g., Netscape 4, you need
more Javascript to handle it.

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors:


<URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>

''Faith without judgement merely degrades the spirit divine.''




这篇关于从下拉列表填充文本框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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