display selected value in dropdown list through javascript
without page refresh

Answer Posted / drorasta

you don't need to use AJAX for this. Just a simple
javascript:

<html>
<body>

<script type="text/javascript">
function showSelected(val){
document.getElementById
('selectedResult').innerHTML = "The selected number is - "
+ val;
}
</script>

<div id='selectedResult'></div>

<select name='test' onChange='showSelected(this.value)'>
<option value='1'>one</option>
<option value='2'>two</option>
</select>

</body>
</html>

Is This Answer Correct ?    375 Yes 116 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is sql injection in php?

533


What is the difference between get & post ?

542


Should I learn php before wordpress?

499


What is in a cookie?

553


what is CURL?

587






What is sorting php?

519


How to open a file for reading?

545


What percentage of websites use php?

507


What is mod_php?

565


Which function gives us the number of affected entries by a query?

521


What are some new features introduced in php7?

8380


Do you have to initialize variables in php?

492


How can we get ip address of a client in php?

544


What is prepared statement in php?

590


What sized websites have you worked on in the past?

539