473,503 Members | 2,197 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 3325
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

24
77287
by: London | last post by:
Hello Can you help me. By ASP How can I get the dropdown(control'name)'s selected value? What is it's property'name?
20
12352
by: Dannyboyo | last post by:
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...
1
5398
by: Jorge Ponte | last post by:
hi I have a Web User Control (ascx) - lets call it "My_WUC" - in a Web form. In that WUC I want have a textbox and a button. I want to click on the button and open a popup (I use javascript for...
5
10276
by: Gil | last post by:
Is there a way to tell if a combbox is in dropdown mode. I tried and if statement combobox.dropdown = true but i get an error. dropwndown function doesnt store if its true or false what i am...
2
2834
by: Peter | last post by:
ASP.NET 2003 In the DataGrid how do I select current cell value in the dropdown box when I click on the edit link, currently when I click on the edit link in the DataGrid the dropdown box...
0
1820
by: TJHerman | last post by:
I have a dropdown list in a Formview that includes a number of fields in the SQLDatasource. I want to be able to get the value of one of the fields in the Datasource that is not the...
11
7359
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...
1
1842
by: Simone | last post by:
Hello, I am new to asp.net and I am in need of help. I have a dropdown that is attached to a SqlDataSource (DataSourceID). The dropdown has one column shown as text and another hidden as the...
1
2280
by: Ted | last post by:
Here is a stored procedure I created in MySQL: CREATE PROCEDURE `sp_find_food`( IN search_string varchar(255) ) BEGIN DECLARE ss VARCHAR(257); SET ss = CONCAT('%',search_string,'%'); SELECT...
0
7205
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,...
0
7093
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...
0
7349
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...
0
5594
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5022
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3177
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3168
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1521
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
746
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.