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
Why overriding is called runtime polymorphism?
What is input sanitization in php?
What is the difference between array_map () and array_shift ()?
What is the use of mysql_fetch_assoc in php?
What are the types of variables in php?
What beforeFilter() is used?
What are the different opening and closing tags available in PHP?
What is the purpose of $_ session?
How does session work in php?
What is difference between get and post?
What is the use of print_r function in php?
Write a program in php to print a table of a number?
What are the differences between GET and POST methods in form submitting?
How can you propagate a session id?
How is it possible to return a value from a function?