when i have select itemfrom dropdownlist i want to call javascript function
how to call onselect event dropdownlist
Collapse
X
-
-
hi ...
use the onchange-event of the <select> - element to invoke a function with the value of the control:
[CODE=html]<script type="text/javascript">
function show_value(val) {
alert(val);
}
</script>
<select name="test" onchange="show_ value(this.valu e);">
<option value="a">a</option>
<option value="b">b</option>
<option value="c">c</option>
</select>[/CODE]
kind regards -
Hallo guys
what if you have code like one below and want to use onselect
Code:<?php echo "<select name='states' onclick='getClientData(this)' >\n"; echo "<option value=''>==== choose title ====</option>\n"; $result=mysql_db_query($db_name,"select `template_id`, `template_detail`,`template_desc` from tbl_templates "); while(list($id, $name,$detail)=mysql_fetch_array($result)){ echo "<option value=\"$id\" >$detail</option> \n" ; } echo "</select>\n"; ?>
Comment
-
you can use this code i hope it will help for you.
Code:<select id="ddlFruits" onchange="GetSelectedTextValue(this)"> <option value=""></option> <option value="1">Apple</option> <option value="2">Mango</option> <option value="3">Orange</option> </select> <script type="text/javascript"> function GetSelectedTextValue(ddlFruits) { var selectedText = ddlFruits.options[ddlFruits.selectedIndex].innerHTML; var selectedValue = ddlFruits.value; alert("Selected Text: " + selectedText + " Value: " + selectedValue); } </script>
Comment
Comment