option

python configparser

孤街醉人 提交于 2019-12-17 18:43:07
configparser模块操作 config.ini 配置文件 [user] user_name = root password = 1234 money = 26985.4578 [connect] ip = 127.0.0.1 port = 8888 [mysql] ip = 192.168.11.122 port = 3369 [mysql_connect] is_true = true is_false = false [redis] name = 192.168.1.22 py 文件 import configparser # 生成 ConfigParser对象 config = configparser.ConfigParser() # 读取配置文件 file_name = 'config.ini' config.read(filenames=file_name, encoding='utf-8') # 获取所有节点sections, 以列表形式返回config parser对象的所有节点信息 all_sections = config.sections() print(all_sections) # ['user', 'connect', 'mysql', 'mysql_connect'] # 获取指定节点的的所有配置信息

thymeleaf multiple selected on edit

。_饼干妹妹 提交于 2019-12-17 18:37:31
问题 I am totally changing this question, as part of it was answered here with great help of Avnish! Tom sent me to the right direction so thank you Tom! My problem is that I do not know how to tell Thymeleaf to preselect object elements when editing it. Let me show you: This solution works: <select class="form-control" id="parts" name="parts" multiple="multiple"> <option th:each="part : ${partsAtribute}" th:selected="${servisAttribute.parts.contains(part)}" th:value="${part.id}" th:text="${part

How to make <option selected=“selected”> set by MySQL and PHP?

一个人想着一个人 提交于 2019-12-17 17:02:32
问题 How to make <option selected="selected"> set by MySQL and PHP? My code: echo '<select>'; $tempholder = array(); $rs = mysql_query("SELECT * FROM id ORDER BY year"); $nr = mysql_num_rows($rs); for ($i=0; $i<$nr; $i++){ $r = mysql_fetch_array($rs); //if($year==$r["year"]){ $selected=' selected="selected"'; }//doesn't work so if (!in_array($r['year'], $tempholder)){ $tempholder[$i] = $r['year']; echo "<option>".$r["year"]."</option>";//<option$selected>... } } unset($tempholder); echo '</select>

select下拉框取值与清空数据

孤人 提交于 2019-12-17 10:46:11
一.获取select被选中的option的值 1.js实现 var selected = document.getElementById(‘selectedId’); //定位id var index = selected.selectedIndex; // 选中索引 var text = selected.options[index].text; // 选中文本 var value = selected.options[index].value; // 选中值 2.jQuery实现 第一种方式 $(’#selectId option:selected’).text();//选中的文本 $(’#selectId option:selected’) .val();//选中的值 $("#selectId ").get(0).selectedIndex;//索引 第二种方式 $("#selectId").find(“option:selected”).text();//选中的文本 $("#selectId").find(“option:selected”).val();//选中的值 $("#selectId").find(“option:selected”).get(0).selectedIndex;//索引 二.给select动态添加值 第一种方法 var select =

使用JQ、BootStrap时,踩过的坑

落爺英雄遲暮 提交于 2019-12-16 17:16:32
(此文用于记录编程过程过程中,遇到的那些令人头皮发麻的坑,以及它们的解决方法) 一、使用bootstrap-select、JQ   日前,要做一个需求,有一个输入框,可以multiple输入,输入的东西还要到数据库判断,其是否存在?后台还要根据这些信息一条一条查找别的表数据,我想这个逻辑实现起来挺麻烦的,干脆在页面就限定用户的选择,就是页面加载的时候就从数据看获取信息,那些,用户就不会输入一些搞怪信息,因此我就找到bootstrap的多选下拉框样式去设计页面,使用JQ、JS来动态追加下拉框可选组件,常规操作如下: success: function (data) { var select = $(".selectpicker"); var opts = ""; var jsonObject = $.parseJSON(data.d); $.each(jsonObject, function (key, value) { if(value!=""){ opts += "<option style='height:26px' value='" + jsonObject[key] + "'>" + jsonObject[key] + "<option/>"; } }); select.append(opts); $('#ResGpSelect').selectpicker(

省市县三级联动(前端后台源码)

时光怂恿深爱的人放手 提交于 2019-12-16 11:45:04
说明:项目中需要用到json的工具包:flexjson-2.1.jar,这个工具包用于将后端数据库返回的list集合转换为字符串 1 < script type ="text/javascript" > 2 function getXHR() { 3 // 定义一个变量,用来接收ajax核心引擎对象 4 var xmlhttp; 5 // 判断当前浏览器 6 if (window.XMLHttpRequest) { 7 // code for IE7+, Firefox, Chrome, Opera, Safari 8 xmlhttp = new XMLHttpRequest(); 9 } else { 10 // code for IE6, IE5 11 xmlhttp = new ActiveXObject( " Microsoft.XMLHTTP " ); 12 } 13 // 将ajax核心引擎对象,返回给调用者 14 return xmlhttp; 15 } 16 window.onload = function () { 17 var xhr = getXHR(); 18 // 打开链接 19 xhr.open( " POST " , " ${root }/loadProvinceServlet " , true ); 20 // 使用表单的方式 POST 数据 21

Pure CSS solution to styling specific <select> options in webkit based browsers?

陌路散爱 提交于 2019-12-14 03:51:03
问题 Quite simply, is there any way to style specific select options in Chrome/Safari? For example, if I had: <select class="the-select"> <option class="header">TECHNICIANS</option> <option>Joe Smith</option> <option>Joe White</option> <option class="header">PRODUCERS</option> <option>Jane Black</option> <option>Cindy Gray</option> </select> Is there anyway to style specifically those options with the class "header"? Obviously in CSS, if you do this: select.the-select option.header { background

optional function to choose for user

核能气质少年 提交于 2019-12-14 03:08:14
问题 I wrote a program using many functions ( def name(): ). These function are summed at the end of code like: a()+b()+c()+d()+e() In what way I can do this: program: >>>a,b,c,d,e are optional fuctions, which one of these functions you want to use in the calculation? user: >>>a,b,d and the program just bring those chosen functions in program. I did search a lot but I could not find sth like this. Thank you for your help. 回答1: You could use a dictionary in the following way. def a(): return 2 + 3

A better way to test the value of an Option?

守給你的承諾、 提交于 2019-12-13 12:53:16
问题 I often find myself with an Option[T] for some type T and wish to test the value of the option against some value. For example: val opt = Some("oxbow") if (opt.isDefined && opt.get == "lakes") //do something The following code is equivalent and removes the requirement to test the existence of the value of the option if (opt.map(_ == "lakes").getOrElse(false)) //do something However this seems less readable to me. Other possibilities are: if (opt.filter(_ == "lakes").isDefined) if (opt.find(_

How can i change select tag option into button group?

早过忘川 提交于 2019-12-13 09:46:44
问题 <div class="form-group"> <label>Select Duration</label> <select name="plan_duration" id="plan_duration" class="selectpicker show-tick form-control" data-live-search="true" style="width:100%;"> </select> </div> Related Scripts $("#plan_name").change(function() { $.getJSON("getduration.php?city="+ $(this).val(), success = function(data) { var options = ""; for(var i = (0); i < data.length; i++) { options += "<option>" + data[i] + "</option>"; } $("#plan_duration").html(""); $("#plan_duration")