Click here to Skip to main content
15,905,877 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
pls any one can help me.iam new to .net help me......
Posted
Updated 6-Aug-13 21:46pm
v2
Comments
What have you tried?

If you have a select element that looks like this:

JavaScript
<select id="ddlViewBy">
<option value="1">test1</option>
<option value="2" selected="selected">test2</option>
<option value="3">test3</option>
</select>

Running this code:

JavaScript
var e = document.getElementById("ddlViewBy");
var strUser = e.options[e.selectedIndex].value;

Would make strUser be 2. If what you actually want is test2, then do this:

JavaScript
var e = document.getElementById("ddlViewBy");
var strUser = e.options[e.selectedIndex].text;

Which would make strUser be test2
 
Share this answer
 
var parm = document.getElementById("<%=DropDownList1.ClientID %>");
        var texte = document.getElementById("<%=txtzip.ClientID %>");
        
        texte.value = parm.options[parm.selectedIndex].text;

try this it will help you
 
Share this answer
 
v3
Comments
Member 10192549 7-Aug-13 8:13am    
Thank You very much for your response sir,
Iam getting error while executing code pls provide the solution.
Uncaught TypeError: Cannot read property 'option' of null
Member 10192549 7-Aug-13 9:14am    
Member 10192549 - 1 hr ago
Thank You very much for your response sir,
Iam getting error while executing code pls provide the solution.
Uncaught TypeError: Cannot read property 'option' of null
try this...:)

HTML
<textarea id="mytext"></textarea>

<select id="dropdown">
    <option value="">None</option>
    <option value="text1">text1</option>
    <option value="text2">text2</option>
    <option value="text3">text3</option>
    <option value="text4">text4</option>
</select>


JavaScript
<script type="text/javascript">
    var mytextbox = document.getElementById('mytext');
    var mydropdown = document.getElementById('dropdown');

    mydropdown.onchange = function(){
          mytextbox.value = mytextbox.value  + this.value; //to appened
         //mytextbox.innerHTML = this.value;
    }
</script>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900