473,763 Members | 6,638 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 3346
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.javas cript 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="docum ent.myForm.F2.v alue=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.javas cript 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="docum ent.myForm.F2.v alue=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.eleme nt['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.selectedIn dex].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.eleme nt['F1'].value = this.options[this.selectedIn dex].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.javas cript 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
77392
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
12435
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 input of product names to put on custom labels we make. Some of the labels will have our product names on them, but the customer can add other products that we do not sell. So, on my product detail page I want a textbox that can have rows copied...
1
5407
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 that), the popup window will have also a text box and a button. when the User click on the button the value on the textbox will be send back to the textbox on My_WUC. I hope I was clear off what I want to do. I've been searching for some ideas...
5
10294
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 trying to do is make an autoscroll combobox. like you have on html textbox's, but this time you hit enter for a change to be made. i do this because i dont want to requery every time a single letter is inputed. it would be too slow. so i make them hit...
2
2854
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 appears in the cell, but allways the first item in the dropdown box is shown not the current cell value? How do I make the current value in the cell automaticaly be selected in the dropdown box.
0
1850
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 Datatextfield or the Datavaluefield from within a Formview control. I know that I can get the data text field or datavalue field by using the following: -Dim ddlCompanyName as DropDownList
11
7397
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 the Dropdown doesnt have any items.. The requirement is that as soon as one goes on typing the letters in the StudentName-textbox the corresponding matching names have to appear
1
1856
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 value. However my SqlDataSouce returns 3 columns but I am only using two for the dropdown (value,text) but the third column I would like to place it in a textbox. So, SqlDataSource has (three columns "A, B, C") it populates a dropdown
1
2301
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 NDB_No,Long_Desc FROM food_des WHERE Long_Desc LIKE ss; END
0
9564
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9387
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10148
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10002
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9938
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8822
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6643
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3917
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 we have to send another system
2
3528
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.