[Javascript] select values to input text problems

Chris Jensen cj at nvisiongr.com
Fri Mar 30 09:36:16 CST 2001


that's all the code, i'm just trying to get it to work.

form.left is where the function call passes (this.form) and is used by the function as the name, and left is the name of the select box.  yeah, a bit confusing.

i'll get all my assignments in order, i usually do that but i'm just trying to get it going.

thanks!

On Friday, March 30, 2001 9:20 AM, Filipiak, Bob <filipiab at atsc.army.mil> wrote:
>RE: [Javascript] select values to input text problems
>First suggest you get into the habit of quoting all
>assignments, i.e. in your "bottomform" name="1",name="1b",name="2",name="2b",action= , etc.
>Second, your function refers to form.left..... while the form
>you are trying to access is "leftform"
>Third, where is the rest of your code?
>
>
>Bob Filipiak (Contractor)
>MCP
>-----Original Message-----
>From: cj at nvisionusa.net [mailto:cj at nvisionusa.net <mailto:cj at nvisionusa.net>]
>Sent: Friday, March 30, 2001 9:05 AM
>To: javascript at latech.edu
>Subject: [Javascript] select values to input text problems
>
>
>i'm trying to get values from a <select> input to populate a
>list of <input type=text> boxes.  what the page is supposed to
>do is be able to pick certain values from a select drop-down,
>add the values to a hidden field while adding the option text
>to the text field.  the function is supposed to get the
>selected option value and option text and put in the
>appropriate form for input into a database.
>perhaps my DOM naming is wrong, i've not done too much work in
>javascript and my syntax is bad.  any tips would be helpful! 
>
>here's my test code:
><html>
><head>
><script language="JavaScript">
>nextBoxNum = 0;
>function NextBox(form) {
>var nextBox = nextBoxNum;
>for (var i = 0; i < form.left.options.length; i++) {
> if (form.left.options[i].selected) {
>document.all.bottomform[nextBox].value = form.left.options[i].text;
>nextBox++;
>document.all.bottomform[nextBox].value = form.left.options[i].value;
>nextBox++;
>}
>}
>nextBoxNum = nextBox;
>}
>
></script>
>
></head>
>
><body bgcolor=#ffffff>
><table cols=2 cellspacing=10 width="100%">
><tr>
> <td width="50%">
> <form name="leftform" action="#" method=get>
> <select name="left" size=4>
>  <option value="value1">Value 1
>  <option value="value2">Value 2
>  <option value="value3">Value 3
>  <option value="value4">Value 4
> </select>
> <input type="button" name="button" value="test" onClick="NextBox(this.form)">
> </form>
> </td>
></tr>
><tr>
> <td width="50%">
> <form name="bottomform" action=#>
> <input type="text" value="" id="0" name=1><br>
> <input type="text" value="" id="1" name=1b><br><br>
> <input type="text" value="" id="2" name=2><br>
> <input type="text" value="" id="3" name=2b>
> 
> </form>
> </td>
></tr>
>
>
></table>
>
></body>
></html>
>TIA!
>chris


-- 
---------------------------------------
c h r i s t o p h e r . a . j e n s e n
---------------------------------------
n Vision/usa inc.
w: http://www.nvisionusa.com
e: cj at nvisiongr.com
p: 6164566566
f: 6164566599






More information about the Javascript mailing list