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
What is sql injection in php?
What is the difference between get & post ?
Should I learn php before wordpress?
What is in a cookie?
what is CURL?
What is sorting php?
How to open a file for reading?
What percentage of websites use php?
What is mod_php?
Which function gives us the number of affected entries by a query?
What are some new features introduced in php7?
Do you have to initialize variables in php?
How can we get ip address of a client in php?
What is prepared statement in php?
What sized websites have you worked on in the past?