473,765 Members | 2,137 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

populate text box from dropdown

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
Jul 20 '05 #1
20 12435
"Dannyboyo" <da******@gto.n et> 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.getEle mentById("names ");
var text = sel.options.val ue;
var out = document.getEle mentById("outpu t");
out.value += text+"\n";
}
</script>

<select id="names">
<option>Produ ct One</option>
<option>Produ ct Two</option>
<option>Produ ct Three</option>
<option>Produ ct 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/rasterTriangleD OM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #2

"Lasse Reichstein Nielsen" <lr*@hotpop.com > wrote in message
news:65******** **@hotpop.com.. .
"Dannyboyo" <da******@gto.n et> 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.getEle mentById("names ");
var text = sel.options.val ue;
var out = document.getEle mentById("outpu t");
out.value += text+"\n";
}
</script>

<select id="names">
<option>Produ ct One</option>
<option>Produ ct Two</option>
<option>Produ ct Three</option>
<option>Produ ct 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/rasterTriangleD OM.html> 'Faith without judgement merely degrades the spirit divine.'

Jul 20 '05 #3
I think the line that reads:
var text = sel.options.val ue;
should read:
var text = sel.options[sel.selectedInd ex].value;

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

"Lasse Reichstein Nielsen" <lr*@hotpop.com > wrote in message
news:65******** **@hotpop.com.. .
"Dannyboyo" <da******@gto.n et> 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.getEle mentById("names ");
var text = sel.options.val ue;
var out = document.getEle mentById("outpu t");
out.value += text+"\n";
}
</script>

<select id="names">
<option>Produ ct One</option>
<option>Produ ct Two</option>
<option>Produ ct Three</option>
<option>Produ ct 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/rasterTriangleD OM.html>
'Faith without judgement merely degrades the spirit divine.'


Jul 20 '05 #4
I think the line:
var text = sel.options.val ue; should read something like:
var text = sel.options[sel.selectedInd ex].value;

Regards,
Chris.

"Desperado" <de************ *@hotmail.net> wrote in message
news:ee******** *************** *******@news.te ranews.com...

"Lasse Reichstein Nielsen" <lr*@hotpop.com > wrote in message
news:65******** **@hotpop.com.. .
"Dannyboyo" <da******@gto.n et> 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.getEle mentById("names ");
var text = sel.options.val ue;
var out = document.getEle mentById("outpu t");
out.value += text+"\n";
}
</script>

<select id="names">
<option>Produ ct One</option>
<option>Produ ct Two</option>
<option>Produ ct Three</option>
<option>Produ ct 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/rasterTriangleD OM.html>
'Faith without judgement merely degrades the spirit divine.'


Jul 20 '05 #5

"Desperado" <de************ *@hotmail.net> wrote in message
news:ee******** *************** *******@news.te ranews.com...

OK, I have a script that does almost exactly what I want, concerning
dropdown selections.
Now I would like to add a text input field that adds the text to the same
area as the dropdown.
Doesn't matter if it submits from the same button as the dropdown or from
it's own button.
My script is below:

<HEAD>
<SCRIPT LANGUAGE="JavaS cript">
<!-- Begin
oldvalue = "";
function passText(passed value) {
if (passedvalue != "") {
var totalvalue = passedvalue+"\n "+oldvalue;
document.displa yform.itemsbox. value = totalvalue;
oldvalue = document.displa yform.itemsbox. value;
}
}
// End -->
</script>
</HEAD>
<BODY>
<form name="selectfor m">
<font face="Arial, Helvetica, Sans Serif" size="3"><b>Sel ect an
Item:</b></font><br>
<select name="dropdownb ox" size=1>
<option value="">Make selection</option>
<option value="Item 1">Item 1</option>
<option value="Item 2">Item 2</option>
<option value="Item 3">Item 3</option>
<option value="Item 4">Item 4</option>
<option value="Item 5">Item 5</option>
<option value="Item 6">Item 6</option>
</select>
<input type=button value="Add to list"

onClick="passTe xt(this.form.dr opdownbox.optio ns[this.form.dropd ownbox.select
edIndex].value);">
</form>
<HR>
<form name="displayfo rm" >
<font face="Arial, Helvetica, Sans Serif" size="3"><b>Ite ms added to
list:</b></font><br>
<textarea cols="80" rows="10" name="itemsbox" ></textarea>
</form>
</body>
</html>
Jul 20 '05 #6
@SM
Dannyboyo a ecrit :

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
You mean a textarea ?
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.


2 soluces :

1) automatic :
==============
<select onchange="nn=th is.options.sele ctedIndex;
(nn==0)? alert('Make an other choice in list') :
this.form['MyTextarea'] += this.options[nn].value+'\n';"
name ... id ... etc >
<option blah blah
<option blah blah
</select>
<textarea name="MyTextare a" id="MyTextarea " rows=8>
2) by force with buttons :
=============== ===========
<html>
<script type="text/javascript"><!--
C = new Array();
function choiceArt(){
chx = document.forms['MyForm']['choicer'];
nn = chx.options.sel ectedIndex;
Article = chx.options[nn].value;
}
function choiceAdd(item) {
if(item=='choic er') {
choiceArt();
C[C.length] = Article;
}
else
C[C.length] = document.forms['MyForm']['other'].value
}
function choiceDel(item) {
if(item=='choic er') {
choiceArt();
for(i=0;i<C.len gth;i++)
if(C[i]==Article) j=i+1*1;
}
else
for(i=0;i<C.len gth;i++)
if(C[i]==document.form s['MyForm']['other'].value)
j=i+1*1;
for(i=j;i<C.len gth;i++)
C[i-1]=C[i];
C.length=(i-1*1);
}
function choiceMem(){
with(document.f orms['MyForm']['Result']) {
value='';
for(i=0;i<C.len gth;i++) {
value += C[i];
if(i<(C.length-1*1)) value += '\n';
}
}
}
function choiceReset() {
C = new Array();
document.forms['MyForm']['Result'].value=' ';
}
// --></script>
<form name="MyForm" id="MyForm" action="p.htm"
onsubmit="alert (this['Result'].value);
// return false;
">
<p><select onchange="nn=th is.options.sele ctedIndex;
if(nn==0) alert('Make an other choice in list');"
name="choicer" id="choicer">
<option selected>Choice an article here
<option value="apples"> Pommes
<option value="bananas" >Bananes
<option value="pears">P oires
</select>
<input type=button onclick="choice Add('choicer'); choiceMem();"
value="Add this article">
<input type=button onclick="choice Del('choicer'); choiceMem();"
value="Delete this article">
<input type=button onclick="choice Reset();"
value="Delette all my choices">
<p>Enter here an other article :
<input type=text name="other" id="other">
<input type=button onclick="choice Add(0);choiceMe m();"
value="Add this new article">
<input type=button onclick="choice Del(0);choiceMe m();"
value="Delete this new article">
<p>That are your choices :
<textarea name="Result" id="Result" rows=12>
</textarea>
<p><input type=submit value="test">
</form>
</html>
Jul 20 '05 #7
@SM
Desperado a ecrit :

"Desperado" <de************ *@hotmail.net> wrote in message
news:ee******** *************** *******@news.te ranews.com...

OK, I have a script that does almost exactly what I want, concerning
dropdown selections.
Now I would like to add a text input field that adds the text to the same
area as the dropdown.
See my other post
<HEAD>
<SCRIPT LANGUAGE="JavaS cript">
<!-- Begin
oldvalue = "";
function passText(passed value) {
if (passedvalue != "") {
var totalvalue = passedvalue+"\n "+oldvalue;
document.displa yform.itemsbox. value = totalvalue;
oldvalue = document.displa yform.itemsbox. value;
if (passedvalue != "")
document.displa yform.itemsbox. value += '\n'+passedvalu e;
}
}
// End -->
</script>
</HEAD>
<BODY>
<form name="selectfor m">
<font face="Arial, Helvetica, Sans Serif" size="3"><b>Sel ect an
Item:</b></font><br>
<select name="dropdownb ox" size=1>
<option value="">Make selection</option>
<option value="Item 1">Item 1</option>
<option value="Item 2">Item 2</option>
<option value="Item 3">Item 3</option>
<option value="Item 4">Item 4</option>
<option value="Item 5">Item 5</option>
<option value="Item 6">Item 6</option>
</select>
<input type=button value="Add to list"

onClick="passTe xt(this.form.dr opdownbox.optio ns[this.form.dropd ownbox.select
edIndex].value);">
onClick="passTe xt(this.options[this.options.se lectedIndex].value);">
</form>
<HR>
<form name="displayfo rm" >
<font face="Arial, Helvetica, Sans Serif" size="3"><b>Ite ms added to
list:</b></font><br>
<textarea cols="80" rows="10" name="itemsbox" ></textarea>
</form>
</body>
</html>

Jul 20 '05 #8

"@SM" <st************ **@wanadoo.fr> wrote in message
news:3F******** *******@wanadoo .fr...

See my other post

It was a beautiful thing.

Thank You
Jul 20 '05 #9
"Chris" <c_********@btc onnect.com> writes:

Please don't top post.
I think the line that reads:
> var text = sel.options.val ue;


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


Actually, I meant to write

var text = sel.value;

The longer version is necessary in, e.g., Netscape 4, but modern
browsers allow you to take the value from the select element itself.

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

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
3806
by: ziggs | last post by:
I have an asp form that has a text box called "colorBox". Just before text box is the word "Color" that is hyperlinked and will run the color.asp if pressed to show all of the colors in a predetermined 3 character code. Ex., BLU for Blue. Now, what I'd like to do is have the user enter all of the data in the main asp form, ex. Name, address, etc. When they come to the "colorBox", they will be allowed to enter "BLU" by hand or click on...
1
3611
by: jzhang29 | last post by:
I have a JSP page and it contains a dropdown list called Office. What I try to do is: When I select different office from this list, the information of office (address, phone,etc) will be populated in same JSP page. I have a java bean called officeBean that contains all the office information.
0
2442
by: Nithin | last post by:
My code as an txt attachment. I have 2 drop down list boxes that on selection populate text boxes from my database table. I am able to display the correct values in these text boxes. I have 2 questions: 1) I would like the user update these text fields that get populated with data from the database. For some reason I get the error when I change the textbox value.
5
5916
by: Rich | last post by:
Hello, I have a search application to search data in tables in a database (3 sql server tables). I populate 2 comboboxes with with data from each table. One combobox will contain unique CompanyID's. The second combobox will contain unique memberID's. Each of the tables that I have to search contain a CompanyID and a memberID field, and these fields are not unique in the respective tables. Like CompanyID, MemberID
0
1613
by: Kay O'Keeffe | last post by:
Hello, I have written my own custom control and I want one of its properties to display as a dropdown list when clicked, so the user can select from the list, it would be similar to the asp textbox control which has a 'TextMode' property and when clicked on, displays as a dropdown list with 3 values, I want to have a similar type property with a dropdown style.
11
7397
by: eureka | last post by:
Hi All, I'm training in Servlets, JSP and JavaScript, I have a web page in which there's a "StudentName" textbox and below it is a "Names" Dropdown list. Initially the Textbox is empty and the Dropdown doesnt have any items.. The requirement is that as soon as one goes on typing the letters in the StudentName-textbox the corresponding matching names have to appear
0
2773
TonFrere
by: TonFrere | last post by:
Hello, I'm building a windows form application in Visual C# using VS 2005. On my form I need to populate a combobox with Invoices# linked to the current reccord's Order# value. This means that: - The combobox should repopulate if the user changes the value of Order#. - The combobox should repopulate if the user moves through records (using the binding navigator. My problem is that whenever I repopulate the combobox, it's value is reset to...
4
4845
by: olidenia | last post by:
I need some help or tips on the following. I have a .sql database file with the folowing structure: DROP TABLE IF EXISTS `car`; CREATE TABLE IF NOT EXISTS `car` ( `id` int(10) default NULL, `Make` text, `Model` text,
0
9568
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9398
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10156
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10007
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9832
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6649
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5419
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3531
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2805
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.