首页前端开发HTML要求在H5中写一个下拉框,点击下拉框内容会出现在文本域中(代码详解)

要求在H5中写一个下拉框,点击下拉框内容会出现在文本域中(代码详解)

时间2024-01-26 19:14:03发布访客分类HTML浏览806
导读:收集整理的这篇文章主要介绍了html5教程-要求在H5中写一个下拉框,点击下拉框内容会出现在文本域中(代码详解),觉得挺不错的,现在分享给大家,也给大家做个参考。小宝典致力于为广大程序猿(媛)提供高品质的代码服务,请大家多多光顾小站,小宝典...
收集整理的这篇文章主要介绍了html5教程-要求在H5中写一个下拉框,点击下拉框内容会出现在文本域中(代码详解),觉得挺不错的,现在分享给大家,也给大家做个参考。小宝典致力于为广大程序猿(媛)提供高品质的代码服务,请大家多多光顾小站,小宝典在此谢过。

朋友出去面试做的面试题,分享了下,我就拿来做做。原题:

HTML中有个下拉框,包含“风,雨,雷,电”,添加事件,当选择风时,文本域内出现选择

 !DOCTYPE htML>
       html lang="en">
       head>
           meta charset="UTF-8">
           tITle>
    Title/title>
       /head>
       body>
       form name="form_name" >
           select name="select_name"   onChange="ShowToText();
     "  >
               option value="1">
    风/option>
               option value="2">
    雨/option>
               option value="3">
    雷/option>
               option value="4">
    电/option>
           /select>
    br>
              textarea rows="3" cols="30"name="textfield_name3">
           /textarea>
       /form>
       /body>
       script language="JavaScript">
       function ShowToText(){
           document.form_name.textfield_name3.value=document.form_name.select_name.options[document.form_name.select_name.selectedIndex].text       }
       /script>
       /html>
      

运行效果

朋友出去面试做的面试题,分享了下,我就拿来做做。原题:

HTML中有个下拉框,包含“风,雨,雷,电”,添加事件,当选择风时,文本域内出现选择

 !DOCTYPE html>
       html lang="en">
       head>
           meta charset="UTF-8">
           title>
    Title/title>
       /head>
       body>
       form name="form_name" >
           select name="select_name"   onChange="ShowToText();
     "  >
               option value="1">
    风/option>
               option value="2">
    雨/option>
               option value="3">
    雷/option>
               option value="4">
    电/option>
           /select>
    br>
              textarea rows="3" cols="30"name="textfield_name3">
           /textarea>
       /form>
       /body>
       script language="JavaScript">
       function ShowToText(){
           document.form_name.textfield_name3.value=document.form_name.select_name.options[document.form_name.select_name.selectedIndex].text       }
       /script>
       /html>
      

运行效果

觉得可用,就经常来吧! 欢迎评论哦! html5教程,巧夺天工,精雕玉琢。小宝典献丑了!

声明:本文内容由网友自发贡献,本站不承担相应法律责任。对本内容有异议或投诉,请联系2913721942#qq.com核实处理,我们将尽快回复您,谢谢合作!

divHTMLpost-format-gallery

若转载请注明出处: 要求在H5中写一个下拉框,点击下拉框内容会出现在文本域中(代码详解)
本文地址: https://pptw.com/jishu/587166.html
以提交问题流程为例描述分答微信h5支付过程 HTML5实例之嵌入式的使用讲解

游客 回复需填写必要信息