/    Sign up×
Community /Pin to ProfileBookmark

Java SCipt Question

i have a drop down menu ..

can i do like , when i choose a value in the drop down menu (LISTBOX)

another text box will show what i choose?

like i have an input text box
<INPUT TYPE=TEXT>

and a drop down menu
<SELECT NAME=’slt’>
<OPTION> 1 </OPTION>
<OPTION> 2 </OPTION>
<OPTION> 3 </OPTION>
</SELECT>

so whenever i choose 1, the text box immediately show me 1

is it possible?

to post a comment
JavaScript

7 Comments(s)

Copy linkTweet thisAlerts:
@PittimannJan 08.2004 — Hi!

You can try something like this:
<i>
</i>&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"&gt;
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Untitled&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;form name="myForm"&gt;
&lt;INPUT TYPE=TEXT name="textfield"&gt;
&lt;SELECT NAME='slt' onchange="document.myForm.textfield.value=this.value"&gt;
&lt;OPTION value=1&gt; 1 &lt;/OPTION&gt;
&lt;OPTION value=2&gt; 2 &lt;/OPTION&gt;
&lt;OPTION value=3&gt; 3 &lt;/OPTION&gt;
&lt;/SELECT&gt;
&lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;

Cheers - Pit
Copy linkTweet thisAlerts:
@ltingauthorJan 08.2004 — emm it works .. but then if i don't change anything the text box is showing nothing, i want to do if i don't click the list box, the text box will still showing the default value of the text box

can do like, if the window first opened,

the text box already show what is the listbox value ..

then when i change value, it shows the value also ..
Copy linkTweet thisAlerts:
@PittimannJan 08.2004 — Hi!
can i do like , when i choose a value in the drop down menu (LISTBOX) another text box will show what i choose?[/QUOTE]
Why didn't you ask, what you really want? Like "I want the textbox to show the value of the listbox"?
<i>
</i>&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"&gt;
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Untitled&lt;/title&gt;
&lt;/head&gt;
&lt;body onload="document.myForm.textfield.value=document.myForm.slt.value"&gt;
&lt;form name="myForm"&gt;
&lt;INPUT TYPE=TEXT name="textfield"&gt;
&lt;SELECT NAME='slt' onchange="document.myForm.textfield.value=this.value"&gt;
&lt;OPTION value=1&gt; 1 &lt;/OPTION&gt;
&lt;OPTION value=2&gt; 2 &lt;/OPTION&gt;
&lt;OPTION value=3&gt; 3 &lt;/OPTION&gt;
&lt;/SELECT&gt;
&lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;

Cheers - Pit
Copy linkTweet thisAlerts:
@ltingauthorJan 08.2004 — ops ... sorry ...

? cos my english quite poor .. don't know how to express it ..


sorry and it works now ?

thanks ?
Copy linkTweet thisAlerts:
@PittimannJan 08.2004 — Hi!

You're welcome ? - and don't worry about your English (mine also is far away from being perfect)...

Cheers - Pit
Copy linkTweet thisAlerts:
@ltingauthorJan 08.2004 — another problem ..


at the <body onload>

if i want another function to be called at the onload how i should write?

<body onload="document.myForm.textfield.value=document.myForm.slt.value" onload="getclose()"> ?????
Copy linkTweet thisAlerts:
@fredmvJan 08.2004 — &lt;body onload="document.myForm.textfield.value=document.myForm.slt.value;getclose();"&gt;
×

Success!

Help @lting spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...