开发者

onclick event in dropdown

开发者 https://www.devze.com 2022-12-24 03:21 出处:网络
<html> <head> </style> <script type=\"text/javascript\"> function ram(){ document.write(\"Hello World!\")
<html>
 <head>
 </style>
  <script type="text/javascript">

   function ram(){
   document.write("Hello World!")
   alert("ok");
   }
  </script>
 </head>
 <bod开发者_运维知识库y>

 <select id="country">
 <option value="India" id="101" onfocus="ram()">India</option>
 <option value="Autralia" id="102" onClick="ram();">Autralia</option>
 <option value="England" id="103" onfocus="ram();">England</option>
 <option value="Ameriaca" id="104" onfocus="ram();">Ameriaca</option>
<option value="Pakistan" selected="selected" id="105" onfocus="ram();" >Pakistan</option>
 </select>
 </body>
</html>

In this above code the event will not fire for dropdown. I try by using focus and click event. I can I do this and I want 1 more thing if I select dropdown value as India, I want to create a dropdown with state (elements are TN, DL, etc) updation.


You want the onchange event on the <select> tag.


Note the Question changed completely while preparing the answer

There is a synatax error in your script

function ram(){ document.write("Hello World!") alert("ok"); }

You are missing a semi-colon between the document.write() and alert()

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号