display selected value in dropdown list through javascript
without page refresh
Answers were Sorted based on User's Feedback
Answer / himanshu
for this purpose we have to use ajax via we call another php
file which make the string of dropdown list
Is This Answer Correct ? | 405 Yes | 109 No |
Answer / 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 |
Answer / dhir
<html>
<body>
<script type="text/javascript">
var show
function showSelected()
{
show
=document.me.test.options[document.me.test.selectedIndex].value;
document.write(show);
}
</script>
<form name="me">
<select name='test' onChange='showSelected()'>
<option value='1'>one</option>
<option value='2'>two</option>
</select>
</form>
</body>
</html>
Is This Answer Correct ? | 169 Yes | 102 No |
Answer / apeksha
<HTML>
<BODY>
<SCRIPT>
function getSelect(s)
{
return s.options[s.selectedIndex].value
}
</SCRIPT>
<SELECT NAME="list" OnChange="location=getSelect(this)">
<OPTION value="#"> Choose a search engine
<OPTION value="http://www.yahoo.com"> Yahoo
<OPTION value="http://www.lycos.com"> Lycos
<OPTION value="http://www.excite.com"> Excite
</SELECT>
</BODY>
</HTML>
Is This Answer Correct ? | 102 Yes | 58 No |
Answer / pinakini
one dropdown value are pass from another dropdown value with
javascript
Is This Answer Correct ? | 80 Yes | 60 No |
Tell me what are the __construct() and __destruct() methods in a php class?
What is implode() in php?
Does jwt protect against csrf?
What is an object in php?
What is the difference between null and empty?
What are classes in php?
How do I run php?
Specify pre-defined classes in php ?
What are some new features introduced in php7?
Is uploaded file php?
Is java is better than php?
what is difference between edit and update?