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 backslash character will match whitespace?
What is the default session time in php?
How a variable is declared in php?
Can we use session in mvc?
How come the code works, but does not for two-dimensional array of mine?
What is the difference between the functions strstr() and stristr()?
How to remove a file?
Php being an open source is there any support available to it?
What is the difference between md5(), crc32() and sha1() crypto on php?
Why do you need php?
What is the difference between static and dynamic websites?
Why laravel is best php framework?
What are different types of Print Functions available in PHP?
How can we change the maximum size of the files to be uploaded?
What is final keyword in php?