It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming JavaScript Forum

Select List

Select List

Postby theapple on Fri Jul 18, 2008 10:44 am

Hi,

I have a Select list and would like to print the text between then
<option>text1</option>
<option>text2</option>
<option>text3</option>
on the screen when I click on the text in the select list. How can I do it?

//Thanks
theapple
 
Posts: 2
Joined: Fri Jul 18, 2008 10:35 am

Postby rangana on Sat Jul 19, 2008 1:15 am

Here's a basic examle for you to keep going:
Code: Select all
<script type="text/javascript">
window.onload=function(){
document.getElementById('opt').onchange=function(){
document.getElementById('show').innerHTML+=this.options[this.selectedIndex].text+'<br>';}}
</script>
<select id="opt">
<option>text1</option>
<option>text2</option>
<option>text3</option>
</select>
<p id="show"></p>


Hope it helps ;)
User avatar
rangana
500+ Club
 
Posts: 935
Joined: Wed Feb 27, 2008 5:14 am
Location: Cebu City Philippines

Thanks that worked perfectly

Postby theapple on Mon Jul 21, 2008 11:43 am

rangana wrote:Here's a basic examle for you to keep going:
Code: Select all
<script type="text/javascript">
window.onload=function(){
document.getElementById('opt').onchange=function(){
document.getElementById('show').innerHTML+=this.options[this.selectedIndex].text+'<br>';}}
</script>
<select id="opt">
<option>text1</option>
<option>text2</option>
<option>text3</option>
</select>
<p id="show"></p>


Hope it helps ;)
theapple
 
Posts: 2
Joined: Fri Jul 18, 2008 10:35 am

Postby rangana on Tue Jul 22, 2008 12:04 am

No problem. Glad to help ;)
User avatar
rangana
500+ Club
 
Posts: 935
Joined: Wed Feb 27, 2008 5:14 am
Location: Cebu City Philippines


Who is online

Users browsing this forum: No registered users and 1 guest