Computer Science Canada

Updating a text box

Author:  Blade [ Thu Nov 20, 2003 2:36 pm ]
Post subject:  Updating a text box

with javascript how can i make it so that you use a <select> list, then when you select one of the lists, a text box will update with a number?

Author:  Amailer [ Thu Nov 20, 2003 5:58 pm ]
Post subject: 

idk, but i think you use the onChange() function.
http://forums.devshed.com/archive/1/2003/10/2/90739

i think idk

Author:  Blade [ Fri Nov 21, 2003 2:56 pm ]
Post subject: 

hmm... how about this

you have a select box, that has a number of options, beside it there is an empty text box. depending on what you select for the drop-down-menu, a number is placed in the text box.. this must be done without refreashing the page.

Author:  Amailer [ Fri Nov 21, 2003 8:08 pm ]
Post subject: 

asdadsa
this?
code:

<SCRIPT LANGUAGE="JavaScript">
<!--
function onChange(object) {
    var Current = object.selectName.selectedIndex;
    object.currentText.value = object.selectName.options[Current].text;
}

//-->
</SCRIPT>

<FORM NAME="formName3" onSubmit="return false;">
<SELECT NAME="selectName" onChange="onChange(this.form)">
<OPTION VALUE="Option 0" SELECTED>Entry 0
<OPTION VALUE="Option 1">Entry 1
<OPTION VALUE="Option 2">Entry 2
<OPTION VALUE="Option 3">Entry 3
<OPTION VALUE="Option 4">Entry 4
<OPTION VALUE="Option 5">Entry 5
</SELECT>
<P>
Text: <INPUT NAME="currentText" TYPE="TEXT" VALUE="">
<P>
</FORM>
<SCRIPT LANGUAGE="JavaScript">
<!--
onChange(document.formName2);
//-->
</SCRIPT>

Author:  Blade [ Sat Nov 22, 2003 2:27 pm ]
Post subject: 

yeah, thats pretty much what i was looking for. thanks


: