472,348 Members | 1,429 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,348 software developers and data experts.

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 3216
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
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
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...
1
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...
5
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...
2
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...
0
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...
11
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"...
1
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...
1
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);...
0
better678
by: better678 | last post by:
Question: Discuss your understanding of the Java platform. Is the statement "Java is interpreted" correct? Answer: Java is an object-oriented...
0
by: teenabhardwaj | last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand....

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.