469,327 Members | 1,337 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,327 developers. It's quick & easy.

Getting the Valu From Dropdown and Setting it as TextBox Text

Hi all,

I have a DropDown and a TextBox just bekeow it...

I have to get the selected value from dropdown and set it as textBox
Text..

The thing is i have to do this Without PostBack.....

Is there any java script to do this functionality...

please reply..

Thanks in Advance..

Sanju.C

Jun 5 '06 #1
6 3126
Charleees said the following on 6/5/2006 1:10 AM:
Hi all,

I have a DropDown and a TextBox just bekeow it...

I have to get the selected value from dropdown and set it as textBox
Text..

The thing is i have to do this Without PostBack.....

Is there any java script to do this functionality...

please reply..


Do I get your grade on your homework as well?

that.value = this.value;

Where that is the textbox, this is the select, search the archives for
the rest and the resolution of getting this and that right.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Jun 5 '06 #2
Charleees wrote:
I have a DropDown and a TextBox just bekeow it...
I have to get the selected value from dropdown and set it as textBox
Text..
The thing is i have to do this Without PostBack.....
Is there any java script to do this functionality...


I think you're looking for something like this:

<form name="myForm">
<select name="F1" size="1"
onChange="document.myForm.F2.value=this.value">
<option value="value1">value1</option>
<option value="value2">value2</option>
<option value="value3">value3</option>
<option value="value4">value4</option>
</select>
<input type="text" name="F2" size="10" value="value1">
</form>

--
Bart

Jun 5 '06 #3
Bart Van der Donck said the following on 6/5/2006 9:00 AM:
Charleees wrote:
I have a DropDown and a TextBox just bekeow it...
I have to get the selected value from dropdown and set it as textBox
Text..
The thing is i have to do this Without PostBack.....
Is there any java script to do this functionality...


I think you're looking for something like this:


And just think, they didn't have to do anything other than ask and
someone writes a solution for them. Aint Usenet grand?

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Jun 5 '06 #4
Randy Webb wrote:
[...]
And just think, they didn't have to do anything other than ask and
someone writes a solution for them.
Yes, you're right of course - I hope the OP liked my pre-fabricated,
tasty cookie with its cool packing design! :-)
Aint Usenet grand?


Definitely - When it comes to technical accuracy, you can trust (some
groups on) usenet (on some type of questions): I mean, if someone's
wrong, somebody else will correct him :-) That so-called "battle test"
is the best guarantee for software quality.

It's good for the OP to read this kind of posts as well, and do some
further study to get better insight in the technologies he's using.
Considering his sort of question, that insight is probably still quite
low at this moment.

--
Bart

Jun 5 '06 #5
Bart Van der Donck wrote:
Randy Webb wrote:

<snip>
Aint Usenet grand?


Definitely - When it comes to technical accuracy, you can trust
(some groups on) usenet (on some type of questions): I mean, if
someone's wrong, somebody else will correct him :-) That so-called
"battle test" is the best guarantee for software quality.

<snip>

That is pretty much an invitation to have someone quibble about your
code ;-)

So here goes:-

| <form name="myForm">

In valid HTML a FORM attribute is required to have an ACTION attribute.
Because of the issues arising directly from attempting to script the
DOMs created from structurally invalid mark-up it is proposed that
mark-up examples, even fragments, should be valid. That is probably
going too far as no evidence has yet been presented that invalid and
missing attributes contribute to scripting issues.

| <select name="F1" size="1"

In a SELECT element that is not MULTIPLE does a - sive="1" - attribute
do anything worthwhile?

| onChange="document.myForm.F2.value=this.value">

You have elected to use the non-(W3C HTML DOM) standard 'shortcut'
property accessors of accessing the FORM element as a property of the
document and the form control as a property of the FORM element.

The W3C HTML DOM standard, and fully back-compatible alternative:-

document.forms['myForm'].element['F1'].value

(or dot notation equivalent) is preferred because it is:-

1. Self documenting, in that looking at the property accessor makes it
obvious that the - document.forms['myForm'] - is a reference to a
form, and that - .element['F1'] - is a reference to an element
(control) within that form. While - document.myForm - may be
confused with references to IMG, EMBED and some other elements that
may also be made available as 'shortcut' named properties of a
document (the name not withstanding as the name of a form in a
non-example should probably say something about the role of the
form), and - .F1 - may be confused with a reference to a property
of the FORM element (some host provided property or an expando).

2. Supported in a wider range of DOMs (as there are good reasons not
to expect XHTML DOMs to support any 'shortcut' property accessors).

However, all form controls have a - form - property that refers to the
form that contains them (or is null if they are not contained in a form)
so the left hand side of the assignment could be shortened to:-

this.form.element['F1'].value

Which makes the form access anonymous (so more flexible/portable).

Although the W3C HTML DOM does specify that the currently selected
OPTION's value be reproduced as a - value - property of the SELECT
element using this sacrifices some back-compatibility with Netscape 4
and some of its contemporaries. The Equally standard:-

this.options[this.selectedIndex].value

- reliably retrieves the value of the selected OPTION in all browsers
known to expose SELECT elements for scripting.

Leaving the assignment as:-

this.form.element['F1'].value = this.options[this.selectedIndex].value;

Richard.
Jun 5 '06 #6
Richard Cornford said the following on 6/5/2006 4:44 PM:
Bart Van der Donck wrote:
Randy Webb wrote: <snip>
Aint Usenet grand?

Definitely - When it comes to technical accuracy, you can trust
(some groups on) usenet (on some type of questions): I mean, if
someone's wrong, somebody else will correct him :-) That so-called
"battle test" is the best guarantee for software quality.

<snip>

That is pretty much an invitation to have someone quibble about your
code ;-)


<snip>
The W3C HTML DOM standard, and fully back-compatible alternative:-

document.forms['myForm'].element['F1'].value


document.forms['myForm'].elements['F1'].value

<g>
--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Jun 5 '06 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

20 posts views Thread by Dannyboyo | last post: by
5 posts views Thread by Gil | last post: by
2 posts views Thread by Peter | last post: by
11 posts views Thread by eureka | last post: by
1 post views Thread by Simone | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by listenups61195 | last post: by
reply views Thread by haryvincent176 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.