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
Does cors prevent csrf?
Is array empty php?
Write a program to get lcm of two numbers using php?
What is $_ env in php?
How to replace a substring in a given string?
How stop the execution of a php scrip?
What is the use of trim function in php?
What does echo mean in php?
What are the different data types in javascript?
Can we override static method?
How do you call a constructor for a parent class?
What is the use of the function htmlentities?
for image work which library?
What is the difference between $argv and $argc? Give example?
> symbol is used to redirect the output of a command. State Whether True or False?