当前位置: 首页 > 编程日记 > 正文

js 实现多选框(复选框) 和单选框,下拉框功能完整示例代码附效果图

<!DOCTYPE html>
<html><head><meta charset="utf-8" /><script src="http://cdn.static.runoob.com/libs/jquery/2.1.1/jquery.min.js"></script><title>单选框,复选框,下拉菜单简单示例</title></head><body><p>单选框示例: (选择性别)</p><!--单选框-->男:<input id='radio_1' type='radio' value='男' name='test1' checked='checked' onchange="demo1(id,value)" />女:<input id='radio_2' type='radio' value='女' name='test1' onchange="demo1(id,value)" /><script type="text/javascript">function demo1(id,value) {alert('我的id是:'+id + '    我的性别是:'+value) //会打印出用户选中的单选框的id}</script><hr /><p>多选框示例: (考试多选答案)</p><!--多选框--><form name="form1" method="post" action=""><input type="checkbox" name="r" value="a">a.我是答案1<br><input type="checkbox" name="r" value="b">b.我是答案2<br><input type="checkbox" name="r" value="c">c.我是答案3<br><input type="checkbox" name="r" value="d">d.我是答案4<br><br><input type="button" onclick="demo2()" value="提交答案"></form><script language="javascript">function demo2() {var arr = [];var r = document.getElementsByName("r");for(var i = 0; i < r.length; i++) {if(r[i].checked) {arr.push(r[i].value);}}alert('我选择的答案是:'+arr)}</script><hr /><p>下拉菜单示例: (选择优惠卷)</p><!--下拉菜单--><select class="" id="self_select" onchange="demo3()"><option>选择优惠券</option><foreach name="list" item="v"><option value="优惠卷1">优惠卷1</option><option value="优惠卷2">优惠卷2</option><option value="优惠卷3">优惠卷3</option></foreach></select><script type="text/javascript">//下拉框内容选择function demo3() {var city_area = $("#self_select").find("option:selected").val();if(city_area == "选择优惠券") {return false;}else{alert('用户下拉菜单选择的优惠卷为:'+city_area)}}</script></body></html>

微信小程序开发交流qq群   173683895

   承接微信小程序开发。扫码加微信。

相关文章:

ruby on rails_我成为了Ruby on Rails和React的贡献者,你也可以

ruby on railsI am really grateful to have contributed to a few open source projects, including two I currently use on a regular basis: Ruby on Rails and React.我非常感谢为一些开源项目做出了贡献&#xff0c;其中包括我目前定期使用的两个项目&#xff1a; Ruby o…

MySQL加密算法

1.不可逆加密&#xff1a; PASSWORD()&#xff0c;ENCRYPT(&#xff0c;)&#xff0c;MD5()&#xff0c;SHA5()。 2.可逆的加密算法&#xff1a; ENCODE(,) DECODE(,)&#xff1a;加密解密字符串。该函数有两个参数&#xff1a;被加密或解密的字符串和作为加密或解密基础的密…

js回调函数和函数带参数的使用示例

微信小程序开发交流qq群 173683895 承接微信小程序开发。扫码加微信。 //demo1 <html><head><meta charset"UTF-8"><script src"http://cdn.static.runoob.com/libs/jquery/2.1.1/jquery.min.js"></script></head>&…

mvc-3模型和数据(1)

MVC和命名空间 var User function(atts) {this.attribute atts || {}; } //和具体user相关的方法 User.prototype.destroy function() {}; //和具体user不相关的函数和变量 User.fetchRemove function() {}; var user new User({name:jinks}); user.destroy();构建对象关系…

初步了解:使用JavaScript进行表达式(De Do Do Do,De Da Da Da)

by Donavon West由Donavon West 初步了解&#xff1a;使用JavaScript进行表达式(De Do Do Do&#xff0c;De Da Da Da) (A first look: do expressions in JavaScript (De Do Do Do, De Da Da Da)) This article is not about about the The Police’s 1980 hit song from alb…

div 下 的img水平居中

设置text-align:center; 这个div必须要设置宽度&#xff1b; 如&#xff1a;{text-align:center; width:100%;}转载于:https://www.cnblogs.com/zzd0916/p/6626772.html

Understanding SOAP

Understanding SOAP转载于:https://www.cnblogs.com/daishuguang/p/4227983.html

js删除组数中的某一个元素(完整代码附效果图)

微信小程序开发交流qq群 173683895 承接微信小程序开发。扫码加微信。 正文&#xff1a; <view class"big-logos"> <imagebindtap"addimg"src../../../image/s.png></image> <blockwx:for"{{img_arr}}"wx:key"in…

c专家编程/c陷阱_如何避免常见的初学者陷阱并像专家一样开始编码

c专家编程/c陷阱by Dmitri Grabov德米特里格拉波夫(Dmitri Grabov) 如何避免常见的初学者陷阱并像专家一样开始编码 (How to avoid common beginner pitfalls and start coding like a pro) Learning to code is tough. We’ve all encountered cryptic errors and code break…

xmpp关于后台挂起的消息接收,后台消息推送,本地发送通知

想问下&#xff0c;在xmpp即时通讯的项目中&#xff0c;我程序如果挂起了&#xff0c;后台有消息过来&#xff0c;我这边的推送不过来&#xff0c;所以我的通知就会收不到消息&#xff0c;当我重新唤醒应用的时候&#xff0c;他才会接收到通知&#xff0c;消息就会推送过来&…

[冲昏头脑]IDEA中的maven项目中学习log4j的日志操作

第一&#xff0c;你要有log4j的对应的包&#xff0c;由于我用的maven&#xff0c;所以直接在pom.xml文件依赖下载则可&#xff0c;如你尚为有此包&#xff0c;请自行百度下载导入&#xff0c;或上http://www.mvnrepository.com/搜索。上如则是我的log4j的包的版本。好了&#x…

女神推荐, 卡片,广告图 ,点击查看更多

微信小程序开发交流qq群 581478349 承接微信小程序开发。扫码加微信。 正文&#xff1a; <view><view classtitle>女神推荐 </view> <image stylemargin-top:25rpx; classtab_img src{{img list_data.q1[1].image}}></image><view classv…

aws lambda_恐怕您正在考虑AWS Lambda的冷启动完全错误

aws lambdaby Yan Cui崔燕 恐怕您正在考虑AWS Lambda的冷启动完全错误 (I’m afraid you’re thinking about AWS Lambda cold starts all wrong) When I discuss AWS Lambda cold starts with folks in the context of API Gateway, I often get responses along the line of…

python tkinter窗口弹出置顶的方法

加上下面两句即可实现root窗口的置顶显示&#xff0c;可以用于某些程序的消息提示&#xff0c;能够弹出到桌面显示 root Tk() root.wm_attributes(-topmost,1) 转载于:https://www.cnblogs.com/shuchengxiang/p/6632140.html

用Quartus II Timequest Timing Analyzer进行时序分析 :实例讲解 (一)

一&#xff0c;概述 用Altera的话来讲&#xff0c;timequest timing analyzer是一个功能强大的&#xff0c;ASIC-style的时序分析工具。采用工业标准--SDC&#xff08;synopsys design contraints&#xff09;--的约束、分析和报告方法来验证你的设计是否满足时序设计的要求。在…

软件工程与软件测试基础知识_这是我在软件工程工作九个月中学到的知识

软件工程与软件测试基础知识I’ve been working for about nine months at Dexter as a software developer. I wrote a blog post about landing the job initially, as well as a technical post about a self positioning component I made in my first couple of months at…

[bzoj1064][Noi2008]假面舞会

题意:有n个人&#xff0c;每个人都有一个标号&#xff0c;每种标号的人只能看见下一个标号的人&#xff08;最后一种标号看见第一种&#xff09;&#xff0c;给定m个关系&#xff0c;求这个关系是否合法以及合法情况下最大和最小的方案数。$n\leqslant 10^{5},m\leqslant 10^{6…

js取一定范围内的随机整数

Math.floor(Math.random()*305 1); Math.random()*305 的作用是取0到305的随机数 加1 就是1到305的随机数, Math.floor是取整数, 所以最后的结果是0到305的随机整数 微信小程序开发交流qq群 173683895 承接微信小程序开发。扫码加微信。

AE,按照属性值关系选择要素

if(axMapControl2.LayerCount<0) { MessageBox.Show("请加载图层后使用该功能","系统提示",MessageBoxButtons.OK,MessageBoxIcon.Warning); } else { ILayer pLayer axMapControl2.get_Layer(0); IFeatureLayer pFeatureLayer pLayer as IFeatureLay…

aws lambda使用_如何使用AWS Lambda和S3构建无服务器URL缩短器

aws lambda使用by Daniel Ireson丹尼尔埃里森(Daniel Ireson) 如何使用AWS Lambda和S3构建无服务器URL缩短器 (How to build a Serverless URL shortener using AWS Lambda and S3) Throughout this post we’ll be building a serverless URL shortener using Amazon Web Ser…

android -volley-请求数据

private List<gson.DataBean>arrGson;//请求的数据 //请求数据的方法 public void initData() { RequestQueue mQueue Volley.newRequestQueue(getApplicationContext()); String url "http://www.fashions88.com/you/HBooks88/GetBooks88Data…

[微信小程序]动画,从顶部掉花的效果(完整代码附效果图)

微信小程序开发交流qq群 173683895 承接微信小程序开发。扫码加微信。 正文&#xff1a; image{ width: 100rpx;height: 100rpx;position: absolute;top: -100rpx; } 如果对您有帮助&#xff0c;请关注我&#xff0c;欢迎加入微信小程序开发交流QQ群&#xff08;173683866&…

pl/sql developer连接远程数据库

本地不安装oracle client程序&#xff0c;直接使用pl/sql developer连接远程数据库 考虑到机子本身资源有限&#xff0c;一个client会占用很多资源&#xff0c;尝试使用不安装客户端的方式进行远程连接。 需要软件&#xff1a;instantclient-basic-win32-10.2.0.5.zip、pl/sql …

工厂用抽象类比接口_用简单的现实类比解释硬编码概念

工厂用抽象类比接口by Samer Buna通过Samer Buna 用简单的现实类比解释硬编码概念 (Hard Coding Concepts Explained with Simple Real-life Analogies) 如何向5岁的孩子解释诸如流&#xff0c;promise&#xff0c;lint和声明性编程之类的编码概念 (How to explain coding con…

[微信小程序]点击切换卡片动画效果

微信小程序开发交流qq群 173683895 承接微信小程序开发。扫码加微信。 正文&#xff1a; 先上效果图, GIF: <!--pages/roll/roll.wxml--> <!-- 单身 --> <block wx:if"{{danshen}}"><view class"card_wrap"><view animatio…

redis学习之——Redis事务(transactions)

Redis事务&#xff1a;可以一次执行多个命令&#xff0c;本质是一组命令的集合。一个事务中的&#xff0c;所有命令都会序列化&#xff0c;按顺序地串行化执行而不会被其它命令插入&#xff0c;不许加塞。 常用命令&#xff1a;MULTI 开启事务 EXEC 提交事务、 DISCARD 放弃…

WordPress页面Page和文章Post的相互转换

1. 进入phpMyAdmin&#xff1b; 2. 进入WordPress对应的数据库&#xff1b; 3. 浏览wp_posts数据表&#xff1b; 4. 找到相应的 页面Page 并编辑&#xff08;找到相应的 文章Post 并编辑&#xff09;&#xff1b; 5. 修改 post_type 为 post&#xff08;page&#xff09;&#…

airbnb_我如何在一个晚上建立音乐工作室的Airbnb

airbnbby Mike Williams由Mike Williams 我如何在一个晚上建立音乐工作室的Airbnb (How I built the Airbnb of music studios in a single evening) Sometimes you come up with an idea that you just know has to be built. That was the case I came up with Studiotime, …

QT学习第8课:QT计算器界面实现

声明&#xff1a;此文章仅是个人在学习狄泰QT课程所做的笔记&#xff0c;文章中包含狄泰资料的&#xff0c;一切版权归狄泰软件所有&#xff01;   第8课是来做一个计算器界面&#xff0c;只是一个界面显示。不过也是挺兴奋的&#xff0c;以前一直对着黑框框&#xff0c;现在…

C# 实现对接电信交费易自动缴费 续(winio/winring0 自动填密码)

自动填密码大家可能都不莫生,最有名的应该是 按键精灵 只要是一个可以输入的地方都可以能过按键精灵来完成输入.我今天要讲的是使用 winio/winring0来完成类似的功能 如果要自动填充密码方式基本上有 消息级的模拟 和 驱动级的模拟, 消息级的模拟如 C# 直接使用 SendKeys 就可以…