1.

 <%@ page language="java" contentType="text/html;charset=UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %> <html>
<head>
<title>上传歌曲</title>
<script type="text/javascript">
var totalSinger = 1;
function selectSingerType(s){
switch(s.options[s.selectedIndex].value){
case "1":
document.getElementById("bandNameDiv").style.display="none";
document.getElementById("addButton").disabled = true;
break;
case "2":
document.getElementById("bandNameDiv").style.display="none";
document.getElementById("addButton").disabled = false;
break;
case "3":
document.getElementById("bandNameDiv").style.display="";
document.getElementById("addButton").disabled = false;
break;
}
var innerHtml = "";
innerHtml += '歌手姓名:<input type="text" name="singerDtos[0].name"><br>';
innerHtml += '歌手国籍:<select name="singerDtos[0].region">';
innerHtml += '<option value="china" selected>华人歌手</option>';
innerHtml += '<option value="korea">韩国歌手</option>';
innerHtml += '<option value="japan">日本歌手</option>';
innerHtml += '<option value="occident">欧美歌手</option>';
innerHtml += '</select><br>';
innerHtml += '歌手性别:<select name="singerDtos[0].sex">';
innerHtml += '<option value="m">男</option>';
innerHtml += '<option value="w">女</option>';
innerHtml += '</select><br>';
document.getElementById("singers").innerHTML = innerHtml;
} function add(){
var innerHtml = document.getElementById("Singers").innerHTML;
innerHtml += '歌手姓名:<input type="text" name="singerDtos[' + totalSinger + '].name"><br>';
innerHtml += '歌手国籍:<select name="singerDtos['+ totalSinger +'].region">';
innerHtml += '<option value="china" selected>华人歌手</option>';
innerHtml += '<option value="korea">韩国歌手</option>';
innerHtml += '<option value="japan">日本歌手</option>';
innerHtml += '<option value="occident">欧美歌手</option>';
innerHtml += '</select><br>';
innerHtml += '歌手性别:<select name="singerDtos[' + totalSinger + '].sex">';
innerHtml += '<option value="m">男</option>';
innerHtml += '<option value="w">女</option>';
innerHtml += '</select><br>';
totalSinger++;
document.getElementById("singers").innerHTML = innerHtml;
}
</script>
</head>
<body>
<div align="center">
<s:form action="uploadSong.action" enctype="multipart/form-data">
<h3 align="center">上传歌曲</h3>
歌曲名称:<input type="text" name="songName"><br>
选择上传的歌曲:<input type="file" name="upload"><br>
歌手类型: <select name="type" onchange="selectSingerType(this)">
<option value="1" selected>单人歌手</option>
<option value="2">组合歌手</option>
<option value="3">乐队</option>
</select>
<div id="bandNameDiv" style="display:none">
乐队名称:<input type="text" name="bandName">
</div>
<div id="singers">
歌手姓名:<input type="text" name="singerDtos[0].name"><br>
歌手国籍: <select name="singerDtos[0].region">
<option value="china" selected>华人歌手</option>
<option value="korea">韩国歌手</option>
<option value="japan">日本歌手</option>
<option value="occident">欧美歌手</option>
</select><br>
歌手性别:<select name="singerDtos[0].sex">
<option value="m">男</option>
<option value="w">女</option>
</select><br>
</div>
<input type="submit" value="上传">
</s:form>
<div id="addSinger" align="center">
<input type="button" value="添加歌手" id="addButton" onclick="add()" disabled>
</div>
</div>
</body>
</html>

js修改页面动态添加input框显示与按钮可编辑的更多相关文章

  1. h5 页面点击添加添加input框

    h5 页面点击添加添加input框 前段时间有个需求,页面要能点击添加按钮控制input框的个数,当时感觉有点难,就没做,这两个又遇到了,没办法写了个简单的 效果图,加号增加,减号减少 直接上代码, ...

  2. JS对select动态添加option操作 (三级联动) (搜索拼接)

    以下纯属自我理解之下再东搜西查的内容~ JS对select动态添加option操作有个高大上的艺名叫多级联动:第一级改变时,第二级跟着变,第二级改变时,第三级跟着变... 本菜鸟是在工作中遇到做收货地 ...

  3. js对select动态添加和删除OPTION

    <select id="ddlResourceType" onchange="getvalue(this)"> </select> 动态 ...

  4. JS对select动态添加options操作[IE&FireFox兼容]

    <select id="ddlResourceType" onchange="getvalue(this)"> </select> 动态 ...

  5. 使用js对select动态添加和删除OPTION示例代码

    动态删除select中的所有options.某一项option以及动态添加select中的项option,在IE和FireFox都能测试成功,感兴趣的朋友可以参考下,希望对大家有所帮助   <s ...

  6. 使用js对select动态添加和删除OPTION

    <select id="ddlResourceType" onchange="getvalue(this)"> </select> 动态 ...

  7. ASP.NET页面动态添加js脚本

    有时我们需要生成自己的JavaScript代码并在运行时动态添加到页面,接下来我们来看一下如何将生成的JavaScript代码动态添加到ASP.NET页面. 为了添加脚本,要将自定义的脚本在一个字符串 ...

  8. 在jsp页面动态添加,删除文本框模块

    jsp代码============ <table class="crud-content-info" > <tr > <td align=" ...

  9. 通过jquery来实现文本框和下拉框动态添加效果,能根据自己的需求来自定义最多允许添加数量,实用的jquery动态添加文本框特效

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

随机推荐

  1. Yii2 跨库orm实现

    近期在对公司的Yii2项目进行子系统拆分,过度阶段难免会有一些跨库操作,原生语句还好,加下库名前缀就可以了,可是到了orm问题就来了,特别是用到model做查询的时候,现在来记录一下跳过的坑, 像下面 ...

  2. lumen url重写

    打开nginx配置文件vhosts.conf,加上try_files $uri $uri/ /index.php?$query_string; ,如下 location / { index index ...

  3. Android OOM解决方案 :

    清单文件里 给Application标签加上android:largeHeap="true"这行代码   这样会给你的app分配一个大内存   如果某个页面在绘制时会耗非常多的内存 ...

  4. 五个知识体系之-SQL学习-第一天

    1. 创建数据库 CREATE DATABASE test1; 2. 删除数据库 DROP DATABASE test1; 3. 创建表 CREATE TABLE tabname (userid BI ...

  5. 内存MCE错误导致暴力扩充messages日志 以及chattr记录

    由于放假,好久没登过服务器,今天登上服务器查看日志意外发现:/var/log/messages文件竟然被撑到20多个G!!!赶紧查看是什么情况,首先,20多个G的文件根本无法查看,因此,我想到了spl ...

  6. eclipse 安装tomcat

  7. ABAP-创建客户

      CALL METHOD CMD_EI_API=>MAINTAIN_BAPI FUNCTION Z_CS_RFC_OA002 . *"------------------------ ...

  8. gradle 跳过junitTest的方法

    Web项目中不长会写JunitTest,但也会写.gradle build的时候回执行test 这项task.如果想跳过,通常有几种方法: 1.在build.gradle 文件中禁用task test ...

  9. .idea文件夹是干嘛的

    question python为什么每次创建的文件目录下都含有.idea/文件夹,该文件夹又是用来干嘛的 answer 当使用pycharm作为IDE时,会自动生成.idea/文件夹来存放项目的配置信 ...

  10. WIFI模块ESP8266的使用指南【转】

    本文转载自:http://www.itdadao.com/articles/c15a814052p0.html 本文主要对讲述ESP8266模块硬件连接工作,以及作为服务器和客户端情况下的配置实现的详 ...