document.querySelectorAll()获取select2标签name属性的选中项值

获取不到 每个name对应的选项值

    for(var i= 0; i< document.querySelectorAll('*[name="xuewei_id"]').length; i ++){
             alert("i值:"+i);
             alert("数组长度:"+document.querySelectorAll('*[name="xuewei_id"]').length);
//          alert(document.querySelectorAll('*[name="xuewei_id"]').innerHTML);

            var options=$("select[name='xuewei_id'] option:selected");
            alert(options.text());
    }

3个回答

    var arr = document.querySelectorAll('*[name="xuewei_id"]');
    for(var i= 0; i< arr.length; i ++){
             alert("i值:"+i);
            var options=$(arr[i]).find("option:selected");
            alert(options.text());
    }

你把相关代码都发出来啊,只给一个这,都不知道你在说什么

/*获取每一个name对应的值*/
$("[name=xuewei_id]").each(function () {
alert($(this).val());
});

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
通过querySelector获取并修改div中class的值

这个程序就是在页面中显示要播放的多媒体文件,同时显示多媒体文件的总时间,当单击播放按钮时,将显示当前播放了的时间。但是缺了一部分代码,有关通过querySelector获取并修改div中class的值的代码。 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="zh-CN"> <head> <title>媒体播放示例</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="description" content="布尔教育 http://www.itbool.com" /> <script> wrapper=document.querySelector('.videochrome'), buffer=document.querySelector('.videochrome.controls.buffer'), playhead=buffer.querySelector('.playhead'), play=wrapper.querySelector('.play'), duration=wrapper.querySelector('.duration'), currentTime=playhead.querySelector('span'); video.addEventListener('loadeddata',canplay,false);//使用事件监听准备播放 function canplay()//调用canplay函数初始化媒体 { initControls(); } function initControls() { duration.innerHTML=asTime(video.duration);//将播放时间以分秒的形式显示 play.onclick=function() { if(video.ended)//如果媒体播放结束,播放时间从0开始 { video.currentTime=0; } video[video.paused?'play':'pause']();//通过三元运算执行播放或暂停 }; } function asTime(t) { t=Math.round(t);//通过Math.round函数对获取到的时间取整 var s=t%60;//转化为分 var m=~(t/60); return m+':'+two(s);//以分:秒的形式输出时间 } function two(s) { s+=""; if (s.length<2)s="0"+s;//对秒数的位数进行判断,位数小于2时以0补位 return s; } video.addEventListener('play',playEvent,false);//使用事件播放 video.addEventListener('pause',pausedEvent,false);//播放暂停 video.addEventListener('ended',function()//播放结束后停止播放 { this.pause();//显示暂停播放 },false); function playEvent() { play.innerHTML='暂停'; } function pausedEvent() { play.innerHTML='播放'; } video.addEventListener('durationchange',updataSeekable,false);//播放的时长被改变 video.addEventListener('timeupdate',updatePlayhead,false);//使用事件监听方式捕捉事件 function updateSeekable() { duration.innerHTML=asTime(video.duration);//媒体文件的总播放时间 } function updatePlayhead() { currentTime.innerHTML=asTime(video.currentTime);//媒体的当前播放时间 } </script> </head> <body> <video src="../video/01.mp4"></video> <div class="videochrome paused"> <div class="controls"> <div class="scrub"> <table width="150" border="0" cellpadding="0" cellspacing="0"> <tr> <td width="50" scope="row"> <button class="play" title="play">播放</button> </td> <td width="50" align="center"> <div class="duration">0:00</div> </td> <td width="50" align="center"> <div class="loaded"> <div class="buffer"> <div class="playhead"> <span>0:00</span> </div> </div> </div> </td> </tr> </table> </div> </div> </div> </body> </html>

js取值,取不到,chrome控制台提示

![图片说明](https://img-ask.csdn.net/upload/201903/12/1552377585_482434.png) 上图是网页结构. ![图片说明](https://img-ask.csdn.net/upload/201903/12/1552400148_838119.png) chrome浏览器右键点橙色方框选择"审查元素" document.querySelector('li[data-pre] > div.order-info > div.order-title.posr > div.order-num > span ').innerHTML 获取蓝色方框内的内容是获取不到(提示:VM419:1 Uncaught TypeError: Cannot read property 'innerHTML' of null).以下命令就可以获取到 window.parent.frames["hashframe"].document.querySelector('li[data-pre] > div.order-info > div.order-title.posr > div.order-num > span ').innerHTML这样就可以获取到"8" ---------------------------------------------------------------分割线 chrome浏览器右键点蓝色方框选择"审查元素" document.querySelector("#wrapper > header > div > div.user-section.pull-left > div.pull-left.box.wm-poi-name.J-box.J-change-poi-wrapper > a > span").innerHTML 获取橙色方块内的内容获取不到(提示:VM590:1 Uncaught TypeError: Cannot read property 'innerHTML' of null) 如果是右键点击橙色方块"审查元素"则同样的命令就能获取到"****蛋糕" 问题1.在右键点蓝色方框选择"审查元素"后如何和获取到黄色框内的内容. 问题2.蓝色方框内的订单号为8,能不能用document.querySelectorALL指定元素下标实现读取7号订单.

onchange()函数不会根据所选的下拉列表在输入文本中获取值

<div class="post-text" itemprop="text"> <p>I have some text that is selected from the dropdown list that I selected, but I have a problem "var Name NodeList []", what should I do?</p> <pre><code>function selectDate(){ var sel = document.querySelectorAll("#dateDisabled"); var opts = sel; var array = []; for(i = 0; i &lt; opts.length; i++) { array.push(opts[i].value); } datesForDisable = array $('.form_date').datetimepicker({ language: 'en', weekStart: 1, todayBtn: 1, autoclose: 1, todayHighlight: 1, startView: 2, minView: 2, forceParse: 0, datesDisabled: datesForDisable }); } </code></pre> </div>

如何获取OPTION的TEXT值

<div class="post-text" itemprop="text"> <p>In this case, only primary dropdown will change, other dropdowns' values will change automatically according to it (so users wont be changing them) I'm trying to get the <strong>Option's TEXT value</strong> using PHP with $_POST. But i can only get it when i <strong>manually</strong> changed the other dropdown . I have tried to use the trigger() method, but it fails to get the option text value. Any idea why the code fails to work. Thank you.</p> <p></p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>function setDropDown() { var index_name = document.getElementsByName('ForceSelection')[0].selectedIndex; var others = document.querySelectorAll('.secondary'); for (var i = 0; i &lt; others.length; i++) { others[i].selectedIndex = index_name; } } &lt;!-- try to get the option text value and pass it to input field--&gt; &lt;!-- Then in the php code use $_POST[] to retrieve the input value--&gt; function setTextField(ddl) { document.getElementById('make_text').value = ddl.options[ddl.selectedIndex].text; } $("select").trigger("change");</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"&gt;&lt;/script&gt; &lt;form action="" method="post"&gt; &lt;div&gt;&lt;b&gt;Primary dropdown:&lt;/b&gt; &lt;select name="ForceSelection" id="ForceSelection" onChange="javascript:return setDropDown();"&gt; &lt;option value="" selected&gt;Select&lt;/option&gt; &lt;option value="treatmentid1"&gt;treatmentname1&lt;/option&gt; &lt;option value="treatmentid2"&gt;treatmentname2&lt;/option&gt; &lt;/select&gt; &lt;/div&gt; &lt;div&gt; &lt;b&gt;Other dropdown 1&lt;/b&gt;: &lt;select class='secondary' id="Qualifications" name="Qualifications" onChange="setTextField(this)"&gt; &lt;option value="select"&gt;select&lt;/option&gt; &lt;option value="treatmentid1"&gt;treatmentname1&lt;/option&gt; &lt;option value="treatmentid2"&gt;treatmentname2&lt;/option&gt; &lt;/select&gt;&lt;/div&gt; &lt;input id="make_text" type="hidden" name="make_text" value="" /&gt; &lt;div&gt; &lt;b&gt;Other dropdown 2&lt;/b&gt;: &lt;select class='secondary' id="Qualifications2" name="Qualifications2"&gt; &lt;option value="select"&gt;select&lt;/option&gt; &lt;option value="treatmentid1"&gt;treatmentname1&lt;/option&gt; &lt;option value="treatmentid2"&gt;treatmentname2&lt;/option&gt; &lt;/select&gt; &lt;/form&gt;</code></pre> </div> </div> <p>PHP Code</p> <pre><code> $value =$_POST['make_text']; </code></pre> </div>

addEventListener重复绑定的问题

写了一段代码 var checkbox={ checkAllBox:'checkAllBox', uncheck:'uncheck', data_checked:'data-checked', checkbox_css:'checkbox-css', checked:'checked', cancelCheck:'cancelCheck', select_one:function () { const checkAllBox=this.checkAllBox; const uncheck=this.uncheck; const checkbox_css=this.checkbox_css; const checked=this.checked; const cancelCheck=this.cancelCheck; var checkOneBox_css=document.querySelectorAll('.'+checkbox_css); for(var i=0;i<checkOneBox_css.length;i++){ (function (i){ if(checkOneBox_css[i].className.indexOf(uncheck)===-1){ checkOneBox_css[i].addEventListener('click',function (event) { console.log(event.target); event.stopPropagation(); var event_name=event.target.className; if(event.target===this&&event.target.className.indexOf(checkAllBox)===-1){ if(event_name.indexOf(checked)!==-1){ event.target.className=event_name.replace(checked,cancelCheck); }else{ if(event_name===checkbox_css){ event.target.className +=' '+checked; }else{ event.target.className=event_name.replace(cancelCheck,checked); } } } },false); } })(i); } }, checkbox:function () { this.select_one(); } }; 每次调用checkbox.checkbox(); 会重复绑定addEventListener,该怎么办。。。

EasyUI combobox无法显示下拉框? 后台已经返回了正确的 JSON 格式的值

## 前台代码: ``` <div class="fitem"> <label>户主名称:</label> <input id="Name" name="holderName" class="easyui-combobox" data-options="valueField:'holder_id', textField:'holderName',panelHeight:'70', url:'ashx/GetName.ashx' " /> </div> ``` ## 后台代码: public void Query(HttpContext context) { //调用B层的方法从而获取数据库的Dataset ADO.SqlAdo ado = new ADO.SqlAdo(); string sql = "select holder_id,holderName from t_householdsInfo"; DataSet ds = ado.getTable(sql); //将Dataset转化为Datable DataTable dt = ds.Tables[0]; int count = dt.Rows.Count; string strJson = Dataset2Json(ds, count);//DataSet数据转化为Json数据 context.Response.Write(strJson);//返回给前台页面 context.Response.End(); ``` ``` ## ## 返回的json: {"total":5,"rows":[{"holder_id":"2","holderName":"王晓宇"},{"holder_id":"3","holderName":"小苏"},{"holder_id":"4","holderName":"万面"},{"holder_id":"7","holderName":"我的家"} ``` ```

使用JS和PHP将<div>保存到MySQL - 可能吗?

<div class="post-text" itemprop="text"> <p>I have a HTML/PHP insert form and one of the entries needs to be refined. The entry in question is the "member".</p> <p>For that I have the following code (credits to @<a href="https://stackoverflow.com/users/8284239/joe-warner">Joe Warner</a> ) which can be tested without the PHP <a href="http://jsfiddle.net/3twuhg72/2/" rel="nofollow noreferrer">here</a></p> <p>Basically I save the <code>&lt;div&gt;</code> to a PHP variable, and print it. It works just fine. </p> <pre><code>&lt;?php $msgs = "&lt;div id='output'&gt;&lt;/div&gt;" echo $msgs; ?&gt; </code></pre> <p>This should be one single string of every member added.</p> <p>The problem is that I can not push into MySQL with the others fields (every field is pushed when submitting). Seems that the variable is first assumed blank and only after <code>getResults()</code> it gets populated.</p> <p>I know it is pretty messy, but for now the form cannot be changed.</p> <p>Any tips?</p> <pre><code>const optionsSelect = [{ id: 1, title: 'Mr' }, { id: 2, title: 'Mrs' } ]; function getResults() { const { selects, inputs } = getInputs(); return selects.reduce((acc, select, i) =&gt; { const { title, name } = getValuesFromElements(select, inputs[i]); msgs = (title &amp;&amp; name) ? `${acc} ${title}. ${name}` : acc; document.getElementById("output").innerHTML = msgs; return (title &amp;&amp; name) ? `${acc} ${title}. ${name}` : acc; }, ''); } function getValuesFromElements(select, {value: name}) { const { title } = optionsSelect[select.value - 1]; return {title, name}; } function getContainerElements(query) { return Array.from(document.querySelectorAll(`#container &gt; ${query}`)); } function getInputs() { const selects = getContainerElements('select'); const inputs = getContainerElements('input'); return { selects, inputs } } function addFields() { const { value: number } = document.getElementById('member'); const container = document.getElementById('container'); while (container.hasChildNodes()) { container.removeChild(container.lastChild); } for (let i = 0; i &lt; number; i++) { const select = document.createElement('select'); for (let j = 0; j &lt; optionsSelect.length; j++) { const options = document.createElement('option'); options.value = optionsSelect[j].id; options.text = optionsSelect[j].title; select.appendChild(options); } container.appendChild(select); container.appendChild(document.createTextNode(' -&gt; Name ' + (i + 1))); const input = document.createElement('input'); input.type = 'text'; container.appendChild(input); container.appendChild(document.createElement('br')); } } &lt;input type="text" id="member" name="member" value=""&gt;Number of members: (max. 10)&lt;br /&gt; &lt;a href="#" id="filldetails" onclick="addFields()"&gt;Fill Details&lt;/a&gt; &lt;a href="#" onclick="console.log(getResults())"&gt;Log results&lt;/a&gt; &lt;div id="container"&gt;&lt;/div&gt; &lt;?php $msgs = "&lt;div id='output'&gt;&lt;/div&gt;" echo $msgs; ?&gt; </code></pre> <p>EDIT</p> <p>I tried to add a second button linked to a PHP function in order to get the current value of $msgs but still doesnt work. It passes the MySQL insertion ("Record updated successfully") but still saves only blank in the DB.</p> <pre><code>&lt;a href="index.php?msgs=true"&gt;Insert into DB&lt;/a&gt; &lt;?php $msgs = "&lt;div id='asservat'&gt;&lt;/div&gt;"; echo $msgs; function insertMsgs() { $server = 'myserver'; $user = 'myuser'; $pass = 'mypass'; $db = 'mydb'; $conn=mysqli_connect($server, $user, $pass, $db); if (mysqli_connect_errno()) { echo ("Connection failed: " . mysqli_connect_error()); } $sql= "UPDATE mytable SET myfield='$msgs' WHERE member=blabla"; if (mysqli_query($conn, $sql)) { echo "Record updated successfully"; } else { echo ("Error updating record: " . mysqli_error($conn)); } mysqli_close($conn); } if (isset($_GET['msgs'])) { insertMsgs(); } </code></pre> </div>

无法使用Javascript取消选中我的框

<div class="post-text" itemprop="text"> <p>I have the following JS wich is actually working and Check all my boxes if the one of the top is checked (currently works) therefore I am unable to UNCHECK them by repeating the same process (unchecking the first box is not uncheckable) ._.</p> <p>I have the following code wich actually call my function each time the checkbox is unchecked or checked:</p> <pre><code>function refresh_checkbox_list(){ // document.getElementById('gdr_select_users').setAttribute("checked"); (function() { var aa = document.querySelectorAll("input[type=checkbox]"); for (var i = 0; i &lt; aa.length; i++){ aa[i].checked = true; } })() } &lt;input type="checkbox" name="gdr_select_all_users" id="gdr_select_all_users" onchange="refresh_checkbox_list()"&gt; &lt;input type="checkbox" name="gdr_select_users" id="gdr_select_users"&gt; </code></pre> <p>Just to say: I am a truly noob of Javascript, I know how I would process it in PHP so it does check and uncheck, but I dont know how does "if" statements work in JS, this is my actual problem..</p> <p>I was thinking about an if statement that checks if my 1st box is checked then check all others boxes, then another statement wich do the exact reverse. Right?</p> <p>I must admit that I have also found that JS on this website (an user wich had a similar case)</p> <p>Thanks forward for any help!</p> </div>

addEventListener监听事件无效?

<script type="text/html" id="option-picker"> <div class="option-picker-addr" id="option-addr">         <div class="option-picker-send">           <span class="option-picker-text">发货</span>           <img class="option-picker-img" src="https://image.hisento.com/assets/index/addr.png">           <div class="option-picker-select">             <span class="option-picker-city" id="city_text">请选择城市</span>             <img class="option-picker-img" src="https://image.hisento.com/assets/index/addr.png">           </div>           <div class="option-picker-mail">快递:免运费</div>           <div class="option-picker-sale">月销:200</div>         </div> </div> </script>  window.LArea = (function() {     var MobileArea = function() {         this.gearArea;         this.data;         this.index = 0;         this.value = [0, 0, 0];         this.currnt = ''     }     MobileArea.prototype = {         init: function(params) {             this.params = params;             var _html=document.getElementById('option-picker').innerHTML;                 document.getElementsByClassName('option-picker1')[0].innerHTML=_html;             this.currnt = params.trigger             this.trigger = document.querySelector(params.trigger);             this.keys = params.keys;             this.type = params.type||1;             switch (this.type) {                 case 1:                 case 2:                     break;                 default:                     throw new Error('错误提示: 没有这种数据源类型');                     break;             }             this.bindEvent();         },         getData: function(callback) {           var _self = this;           if (typeof _self.params.data == "object") {             _self.data = _self.params.data;             callback();           } else {             var xhr = new XMLHttpRequest();             xhr.open('get', _self.params.data);             xhr.onload = function(e) {               if ((xhr.status >= 200 && xhr.status < 300) || xhr.status === 0) {                 var responseData = JSON.parse(xhr.responseText);                 _self.data = responseData.data;                 if (callback) {                   callback()                 };               }             }             xhr.send();           }         },         bindEvent: function() {             var _self = this;             //呼出插件             function popupArea(e) {               console.log(11)                 _self.gearArea = document.createElement("div");                 _self.gearArea.className = "gearArea";                 _self.gearArea.innerHTML = '<div class="area_ctrl slideInUp">' +                     '<div class="area_btn_box">' +                     '<div class="area_btn larea_cancel">取消</div>' +                     '<div class="area_btn larea_finish">确定</div>' +                     '</div>' +                     '<div class="area_roll_mask">' +                     '<div class="area_roll">' +                     '<div>' +                     '<div class="gear area_province" data-areatype="area_province"></div>' +                     '<div class="area_grid">' +                     '</div>' +                     '</div>' +                     '<div>' +                     '<div class="gear area_city" data-areatype="area_city"></div>' +                     '<div class="area_grid">' +                     '</div>' +                     '</div>' +                     '<div>' +                     '<div class="gear area_county" data-areatype="area_county"></div>' +                     '<div class="area_grid">' +                     '</div>' +                     '</div>' +                     '</div>' +                     '</div>' +                     '</div>';                 document.body.appendChild(_self.gearArea);                 areaCtrlInit();                 var larea_cancel = _self.gearArea.querySelector(".larea_cancel");                 larea_cancel.addEventListener('touchstart', function(e) {                     _self.close(e);                 });                 var larea_finish = _self.gearArea.querySelector(".larea_finish");                 larea_finish.addEventListener('touchstart', function(e) {                     _self.finish(e);                 });                 var area_province = _self.gearArea.querySelector(".area_province");                 var area_city = _self.gearArea.querySelector(".area_city");                 var area_county = _self.gearArea.querySelector(".area_county");                 area_province.addEventListener('touchstart', gearTouchStart);                 area_city.addEventListener('touchstart', gearTouchStart);                 area_county.addEventListener('touchstart', gearTouchStart);                 area_province.addEventListener('touchmove', gearTouchMove);                 area_city.addEventListener('touchmove', gearTouchMove);                 area_county.addEventListener('touchmove', gearTouchMove);                 area_province.addEventListener('touchend', gearTouchEnd);                 area_city.addEventListener('touchend', gearTouchEnd);                 area_county.addEventListener('touchend', gearTouchEnd);             }             //初始化插件默认值             function areaCtrlInit() {                 _self.gearArea.querySelector(".area_province").setAttribute("val", _self.value[0]);                 _self.gearArea.querySelector(".area_city").setAttribute("val", _self.value[1]);                 _self.gearArea.querySelector(".area_county").setAttribute("val", _self.value[2]);                 switch (_self.type) {                     case 1:                         _self.setGearTooth(_self.data);                         break;                     case 2:                         _self.setGearTooth(_self.data[0]);                         break;                 }             }             //触摸开始             function gearTouchStart(e) {                 e.preventDefault();                 var target = e.target;                 while (true) {                     if (!target.classList.contains("gear")) {                         target = target.parentElement;                     } else {                         break                     }                 }                 clearInterval(target["int_" + target.id]);                 target["old_" + target.id] = e.targetTouches[0].screenY;                 target["o_t_" + target.id] = (new Date()).getTime();                 var top = target.getAttribute('top');                 if (top) {                     target["o_d_" + target.id] = parseFloat(top.replace(/em/g, ""));                 } else {                     target["o_d_" + target.id] = 0;                 }                 target.style.webkitTransitionDuration = target.style.transitionDuration = '0ms';             }             //手指移动             function gearTouchMove(e) {                 e.preventDefault();                 var target = e.target;                 while (true) {                     if (!target.classList.contains("gear")) {                         target = target.parentElement;                     } else {                         break                     }                 }                 target["new_" + target.id] = e.targetTouches[0].screenY;                 target["n_t_" + target.id] = (new Date()).getTime();                 var f = (target["new_" + target.id] - target["old_" + target.id]) * 30 / window.innerHeight;                 target["pos_" + target.id] = target["o_d_" + target.id] + f;                 target.style["-webkit-transform"] = 'translate3d(0,' + target["pos_" + target.id] + 'em,0)';                 target.setAttribute('top', target["pos_" + target.id] + 'em');                 if(e.targetTouches[0].screenY<1){                     gearTouchEnd(e);                 };             }             //离开屏幕             function gearTouchEnd(e) {                 e.preventDefault();                 var target = e.target;                 while (true) {                     if (!target.classList.contains("gear")) {                         target = target.parentElement;                     } else {                         break;                     }                 }                 var flag = (target["new_" + target.id] - target["old_" + target.id]) / (target["n_t_" + target.id] - target["o_t_" + target.id]);                 if (Math.abs(flag) <= 0.2) {                     target["spd_" + target.id] = (flag < 0 ? -0.08 : 0.08);                 } else {                     if (Math.abs(flag) <= 0.5) {                         target["spd_" + target.id] = (flag < 0 ? -0.16 : 0.16);                     } else {                         target["spd_" + target.id] = flag / 2;                     }                 }                 if (!target["pos_" + target.id]) {                     target["pos_" + target.id] = 0;                 }                 rollGear(target);             }             //缓动效果             function rollGear(target) {                 var d = 0;                 var stopGear = false;                 function setDuration() {                     target.style.webkitTransitionDuration = target.style.transitionDuration = '200ms';                     stopGear = true;                 }                 clearInterval(target["int_" + target.id]);                 target["int_" + target.id] = setInterval(function() {                     var pos = target["pos_" + target.id];                     var speed = target["spd_" + target.id] * Math.exp(-0.03 * d);                     pos += speed;                     if (Math.abs(speed) > 0.1) {} else {                         var b = Math.round(pos / 2) * 2;                         pos = b;                         setDuration();                     }                     if (pos > 0) {                         pos = 0;                         setDuration();                     }                     var minTop = -(target.dataset.len - 1) * 2;                     if (pos < minTop) {                         pos = minTop;                         setDuration();                     }                     if (stopGear) {                         var gearVal = Math.abs(pos) / 2;                         setGear(target, gearVal);                         clearInterval(target["int_" + target.id]);                     }                     target["pos_" + target.id] = pos;                     target.style["-webkit-transform"] = 'translate3d(0,' + pos + 'em,0)';                     target.setAttribute('top', pos + 'em');                     d++;                 }, 30);             }             //控制插件滚动后停留的值             function setGear(target, val) {                 val = Math.round(val);                 target.setAttribute("val", val);                 switch (_self.type) {                     case 1:                          _self.setGearTooth(_self.data);                         break;                     case 2:                      switch(target.dataset['areatype']){                          case 'area_province':                          _self.setGearTooth(_self.data[0]);                              break;                          case 'area_city':                              var ref = target.childNodes[val].getAttribute('ref');                              var childData=[];                              var nextData= _self.data[2];                              for (var i in nextData) {                                  if(i==ref){                                     childData = nextData[i];                                     break;                                  }                              };                         _self.index=2;                         _self.setGearTooth(childData);                              break;                      }                 }                              }             _self.getData(function() {             //   _self.trigger.addEventListener('click', popupArea);             console.log(_self.trigger)               _self.trigger.addEventListener('click', function(){                   alert(111)               });             });         },         //重置节点个数         setGearTooth: function(data) {             var _self = this;             var item = data || [];             var l = item.length;             var gearChild = _self.gearArea.querySelectorAll(".gear");             var gearVal = gearChild[_self.index].getAttribute('val');             var maxVal = l - 1;             if (gearVal > maxVal) {                 gearVal = maxVal;             }             gearChild[_self.index].setAttribute('data-len', l);             if (l > 0) {                 var id = item[gearVal][this.keys['id']];                 var childData;                 switch (_self.type) {                     case 1:                     childData = item[gearVal].child                         break;                     case 2:                      var nextData= _self.data[_self.index+1]                       for (var i in nextData) {                          if(i==id){                             childData = nextData[i];                             break;                          }                      };                         break;                 }                 var itemStr = "";                 for (var i = 0; i < l; i++) {                     itemStr += "<div class='tooth'  ref='" + item[i][this.keys['id']] + "'>" + item[i][this.keys['name']] + "</div>";                 }                 gearChild[_self.index].innerHTML = itemStr;                 gearChild[_self.index].style["-webkit-transform"] = 'translate3d(0,' + (-gearVal * 2) + 'em,0)';                 gearChild[_self.index].setAttribute('top', -gearVal * 2 + 'em');                 gearChild[_self.index].setAttribute('val', gearVal);                 _self.index++;                 if (_self.index > 2) {                     _self.index = 0;                     return;                 }                 _self.setGearTooth(childData);             } else {                 gearChild[_self.index].innerHTML = "<div class='tooth'></div>";                 gearChild[_self.index].setAttribute('val', 0);                 if(_self.index==1){                     gearChild[2].innerHTML = "<div class='tooth'></div>";                     gearChild[2].setAttribute('val', 0);                 }                 _self.index = 0;             }         },         finish: function(e) {             var _self = this;             var area_province = _self.gearArea.querySelector(".area_province");             var area_city = _self.gearArea.querySelector(".area_city");             var area_county = _self.gearArea.querySelector(".area_county");             var provinceVal = parseInt(area_province.getAttribute("val"));             var provinceText = area_province.childNodes[provinceVal].textContent;             var provinceCode = area_province.childNodes[provinceVal].getAttribute('ref');             var cityVal = parseInt(area_city.getAttribute("val"));             var cityText = area_city.childNodes[cityVal].textContent;             var cityCode = area_city.childNodes[cityVal].getAttribute('ref');             var countyVal = parseInt(area_county.getAttribute("val"));             var countyText = area_county.childNodes[countyVal].textContent;             var countyCode = area_county.childNodes[countyVal].getAttribute('ref');             _self.trigger.value = provinceText + ((cityText)?(',' + cityText):(''))+ ((countyText)?(',' + countyText):(''));             _self.value = [provinceVal, cityVal, countyVal];             if(this.valueTo){                 this.valueTo.value= provinceCode +((cityCode)?(',' + cityCode):('')) + ((countyCode)?(',' + countyCode):(''));             }             _self.close(e);         },         close: function(e) {             e.preventDefault();             var _self = this;             var evt = new CustomEvent('input');             _self.trigger.dispatchEvent(evt);             document.body.removeChild(_self.gearArea);             _self.gearArea=null;         }     }     return MobileArea;   })();   window.onload = function(){    var LAreaData=[{     "id":"2","name":"\u5317\u4eac\u5e02",     "child":[{       "id":"2288","name":"\u4e1c\u57ce\u533a"},       {"id":"2301","name":"\u5927\u5174\u533a"},       {"id":"2300","name":"\u660c\u5e73\u533a"},       {"id":"2299","name":"\u987a\u4e49\u533a"},       {"id":"2298","name":"\u901a\u5dde\u533a"},       {"id":"2297","name":"\u623f\u5c71\u533a"},       {"id":"2296","name":"\u95e8\u5934\u6c9f\u533a"},       {"id":"2295","name":"\u6d77\u6dc0\u533a"},       {"id":"2294","name":"\u77f3\u666f\u5c71\u533a"},       {"id":"2293","name":"\u4e30\u53f0\u533a"},       {"id":"2292","name":"\u671d\u9633\u533a"},       {"id":"2291","name":"\u5ba3\u6b66\u533a"},       {"id":"2290","name":"\u5d07\u6587\u533a"},       {"id":"2289","name":"\u897f\u57ce\u533a"},       {"id":"2051","name":"\u5ef6\u5e86\u53bf",       "child":[         {"id":"2099","name":"\u5ef6\u5e86\u9547"},         {"id":"2100","name":"\u6c38\u5b81\u9547"},         {"id":"2101","name":"\u5eb7\u5e84\u9547"},         {"id":"2102","name":"\u5927\u6986\u6811\u9547"},         {"id":"2103","name":"\u4e95\u5e84\u9547"},         {"id":"2104","name":"\u516b\u8fbe\u5cad\u9547"}       ]     }]   }];   var area1 = new LArea();   area1.init({       'trigger': '#city_text', //触发选择控件的文本框,同时选择完毕后name属性输出到该位置       'keys': {           id: 'id',           name: 'name'       }, //绑定数据源相关字段 id对应valueTo的value属性输出 name对应trigger的value属性输出       'type': 1, //数据源类型       'data': LAreaData //数据源   }); } _self.trigger.addEventListener('click', function(){                   alert(111)               });这个监听事件怎么无效的

我有一个输入为图像的表单,我无法弄清楚如何将输入标签的name属性发送到mysql数据库?

<div class="post-text" itemprop="text"> <p>So I want the user to select one of the images from a form displayed but I do not want to upload an image, just send the name of that image to my database.</p> <p>I saw a couple of solutions about uploading images to the database, but I can not figure out how to just send the name of the image selected by the user</p> <p>The end result would be basically the information sent to mysql database.</p> <p></p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;p class="questions"&gt;What type of roof do you have?&lt;/p&gt; &lt;div id="roof-type"&gt; &lt;table&gt; &lt;tr&gt; &lt;form method="post" action="action.php"&gt; &lt;input type="image" src="images/asphalt.png" name="asphalt" id="asphalt" /&gt; &lt;input type="image" src="images/metal.png" name="metal" id="metal" /&gt; &lt;input type="image" src="images/flat.png" name="flat" id="flat" /&gt; &lt;input type="image" src="images/clay.png" name="clay" id="clay" /&gt; &lt;input type="image" src="images/cement.png" name="cement" id="cement" /&gt; &lt;input type="image" src="images/other.png" name="other-roof" id="other-roof" /&gt; &lt;input type='hidden' name='roof_type' /&gt; &lt;/form&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/div&gt; &lt;script&gt; let input = document.querySelector('input[type="hidden"][name="roof_type"]'); let col = document.querySelectorAll('input[type="image"]'); Array.prototype.slice.call(col).forEach(img =&gt; { img.addEventListener('click', function(e) { e.preventDefault(); input.value = this.name; input.parentNode.submit(); }) }) &lt;/script&gt;</code></pre> </div> </div> <pre class="lang-html prettyprint-override"><code>&lt;?php $conn = new mysqli($servername, $username, $password, $dbname); // Check connection if ($conn-&gt;connect_error) { die("Connection failed: " . $conn-&gt;connect_error); } $roof_type = $_POST['roof_type']; $sql = "INSERT INTO testing_database ". "(roof_type) ". "VALUES($roof_type)"; mysql_select_db('test'); $retval = mysql_query( $sql, $conn ); if(! $retval ) { die('Could not enter data: ' . mysql_error()); } echo "Entered data successfully "; ?&gt; </code></pre> <p>I was trying to check if I see any output if I echo roof_type, but I don't see anything at the moment, and these are the following errors I am getting:</p> <ul> <li>Notice: Undefined variable: link in C:\xampp\htdocs\test\action.php Notice: Undefined index: roof_type in C:\xampp\htdocs\test\action.php Warning: mysqli_real_escape_string() expects parameter 1 to be mysqli, null given in C:\xampp\htdocs\test\action.php</li> </ul> </div>

在简单的HTML PHP表单中从JQuery返回PHP变量

<div class="post-text" itemprop="text"> <p>so I have a very simple html form (form.php) and use php to inserted into a SQL DB.</p> <p>The problem is that I have a dynamic add names feature (get_names.html), which I want to have the return from the javascript function "post()" to my PHP variable $name, so I can submit all the form at once.</p> <p>For the field name, I use AJAX with PHP (return_names.php) to retrieve the 'name' as a string, and it works with $_POST.</p> <p>How to pass the return from return_names.php to $name in the form? </p> <p>form.php</p> <pre><code> &lt;meta http-equiv="Content-type" content="text/html; charset=UTF- 8" /&gt; &lt;html&gt; &lt;body&gt; &lt;head&gt; &lt;script type="text/javascript" src="myjquery.js"&gt;&lt;/script&gt; &lt;/head&gt; &lt;?php include("connect-db.php"); function renderForm($id = '', $place = '', $name ='') { ?&gt; &lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"&gt; &lt;form action="" method="post"&gt; &lt;div&gt; &lt;?php if ($id != '') { ?&gt; &lt;input type="hidden" name="id" value="&lt;?php echo $id; ?&gt;" /&gt; &lt;p&gt;ID: &lt;?php echo $id; ?&gt;&lt;/p&gt; &lt;?php } ?&gt; &lt;br/&gt; &lt;strong&gt;Place: &lt;/strong&gt; &lt;input type="text" name="place" value="&lt;?php echo $place; ?&gt;"/&gt;&lt;br/&gt; &lt;br/&gt; &lt;strong&gt;Name: &lt;/strong&gt; &lt;input type="text" name="name" value="&lt;?php echo $name; ?&gt;"/&gt;&lt;br/&gt; &lt;br/&gt; &lt;?php if (isset($_POST['submit'])) { $id = htmlentities($_POST['id'], ENT_QUOTES); $place = htmlspecialchars($_POST['place'], ENT_QUOTES); $name = htmlspecialchars($_POST['name'], ENT_QUOTES); ($stmt = $mysqli-&gt;prepare("INSERT mydb (id, place, name) VALUES (?, ?, ?)")); { $stmt-&gt;bind_param("iss", $id, $place, $name); $stmt-&gt;execute(); $stmt-&gt;close(); } } } ?&gt; &lt;br/&gt; &lt;/div&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>get_names.html</p> <pre><code>&lt;head&gt; &lt;script src="jquery-3.3.1.min.js"&gt;&lt;/script&gt; &lt;/head&gt; &lt;script type='text/javascript'&gt; const optionsSelect = [{ id: 1, title: 'Mr' }, { id: 2, title: 'Mrs' } ]; function getResults() { const { selects, inputs } = getInputs(); return selects.reduce((acc, select, i) =&gt; { const { title, name } = getValuesFromElements(select, inputs[i]); msg = (title &amp;&amp; name) ? `${acc} ${title}. ${name}` : acc; document.getElementById("asservat").innerHTML = msg; var msgs = msg; //return (title &amp;&amp; name) ? `${acc} ${title}. ${name}` : acc; return msgs; }, ''); } function getResultsAsArray() { const { selects, inputs } = getInputs(); const getFieldValues = (select, i) =&gt; { const { title, name } = getValuesFromElements(select, inputs[i]); return (title &amp;&amp; name) ? `${title}. ${name}` : ''; }; return selects.map(getFieldValues).filter(Boolean); } function getValuesFromElements(select, {value: name}) { const { title } = optionsSelect[select.value - 1]; return {title, name}; } function getContainerElements(query) { return Array.from(document.querySelectorAll(`#container &gt; ${query}`)); } function getInputs() { const selects = getContainerElements('select'); const inputs = getContainerElements('input'); return { selects, inputs } } function addFields() { const { value: number } = document.getElementById('member'); const container = document.getElementById('container'); while (container.hasChildNodes()) { container.removeChild(container.lastChild); } for (let i = 0; i &lt; number; i++) { const select = document.createElement('select'); for (let j = 0; j &lt; optionsSelect.length; j++) { const options = document.createElement('option'); options.value = optionsSelect[j].id; options.text = optionsSelect[j].title; select.appendChild(options); } container.appendChild(select); container.appendChild(document.createTextNode(' -&gt; Name ' + (i + 1))); const input = document.createElement('input'); input.type = 'text'; container.appendChild(input); container.appendChild(document.createElement('br')); } } &lt;/script&gt; &lt;input type="text" id="member" name="member" value=""&gt;Number of members: (max. 10)&lt;br /&gt; &lt;a href="#" id="filldetails" onclick="addFields()"&gt;Fill Details&lt;/a&gt; &lt;a href="#" onclick="console.log(getResults())"&gt;Log results&lt;/a&gt; &lt;p id="container"&gt;&lt;/p&gt; &lt;div id="asservat"&gt;&lt;/div&gt; &lt;input type="button" value="Submit" onclick="post();"&gt;ajax&lt;br /&gt; &lt;script type="text/javascript"&gt; function post(){ var name = getResults(); $.post('return_names.php',{postname:name}, function(data){ $('#name').html(data); }); return $('#name').html(data); } &lt;/script&gt; </code></pre> <p>return_names.php</p> <pre><code> &lt;?php function data() { $name = $_POST['postname']; echo "Name as string -&gt;", $name, " &lt;- here"; return $name; } data(); ?&gt; </code></pre> <p>I expect to echo $name in the form.php and get the strings returned by "return_names.php" for example "Mr. Ann Mrs. Anna"</p> </div>

在ajax响应上应用表类

<div class="post-text" itemprop="text"> <p>I have applied classes on my <code>&lt;table&gt;</code> and I am creating my rows from AJAX response in JSON. My issue is, listing is shown for 3 different radios selection, but the table classes are not being applied on the inserted rows so it escapes the pagination classes data. How can I rectify this? I searched a lot, and asked a lot many forums but could not get any outcome.</p> <p><code>&lt;table id="example" class="table table-striped table-hover table-bordered dataTableReport dt-responsive nowrap" cellspacing="0" width="100%"&gt;</code></p> <p>Any help or advice will be welcomed and appreciated.</p> <pre><code>&lt;?php include 'blocks/headerInc.php' ; ?&gt; &lt;?php ob_start(); $errmsg = "" ; $module_id = ''; $query = ''; $date_from = ''; $date_to = ''; $status =''; $check =''; $disabled=''; $row=''; $sqlQuery = "SELECT * FROM tbl_user WHERE type = 3 AND status = 0 AND registration_type = 0"; ?&gt; &lt;div class="container pagecontainer"&gt; &lt;!-- Static navbar --&gt; &lt;div class="row row-offcanvas row-offcanvas-right"&gt; &lt;!--/.col-xs-12.col-sm-9--&gt; &lt;div class="col-sm-3 col-md-3 sidebar" id="sidebar"&gt; &lt;div id="left_panel" class="clearfix left"&gt; &lt;?php include 'blocks/leftnavInc.php' ; ?&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="col-xs-12 col-sm-9 page-right"&gt; &lt;div class="panel panel-primary"&gt; &lt;div class="panel-heading"&gt;Candidate Approval&lt;/div&gt; &lt;div class="panel-body"&gt; &lt;div class="column col-sm-offset-0"&gt; &lt;form id="selection" method="GET" &gt; &lt;input type='radio' name='users' value='unapproved' checked /&gt; Unapproved Candidates &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;input type='radio' name='users' value='approved' /&gt; Approved Candidates &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;input type='radio' id='show' name='users' value='all' /&gt; All Candidates &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;table id="example" class="table table-striped table-hover table-bordered dataTableReport dt-responsive nowrap" cellspacing="0" width="100%"&gt; &lt;thead&gt; &lt;tr&gt; &lt;th&gt;S.No.&lt;/th&gt; &lt;th&gt;Email ID&lt;/th&gt; &lt;th&gt; Reference ID&lt;/th&gt; &lt;th&gt;Name&lt;/th&gt; &lt;th&gt;Mobile No.&lt;/th&gt; &lt;th&gt;Registration Date&lt;/th&gt; &lt;th&gt;Check for Approval &lt;input type="checkbox" id="select_all" name="all_check[]" &lt;?php echo $disabled ;?&gt; class="checkbox" value= "&lt;?php //echo $row['id']; ?&gt;"&gt; &lt;/th&gt; &lt;/tr&gt; &lt;/thead&gt; &lt;tbody id=datashow&gt;&lt;/tbody&gt; &lt;/table&gt; &lt;input type="submit" name ="all_send" value="Approve" style="display: none; float: right;" id="one" class="btn btn-success"&gt; &lt;/form&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;!--/row--&gt; &lt;/div&gt; &lt;!--/.sidebar-offcanvas--&gt; &lt;/div&gt; &lt;/div&gt; &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"&gt; &lt;/script&gt; &lt;script&gt; $('#selection').change ( function() { var selected_value = $("input[name='users']:checked").val(); $.ajax ( { url: "report_ajax.php", type: "POST", cache: false, data: { selected_value : selected_value }, success: function(response) { console.log(response); var len = response.length; $("#datashow").empty(); for(var i=0; i&lt;len; i++){ var id = response[i].id; var email = response[i].email; var employee_id = response[i].employee_id; var first_name = response[i].first_name; var middle_name = response[i].middle_name; var last_name = response[i].last_name; var mobile = response[i].mobile; var created_on = response[i].created_on; var disabled = response[i].disabled; var users = response[i].users; var tr_str = "&lt;tr&gt;" + "&lt;td&gt;" + (i+1) + "&lt;/td&gt;" + "&lt;td&gt;" + email + "&lt;/td&gt;" + "&lt;td&gt;" + employee_id + "&lt;/td&gt;" + "&lt;td&gt;" + first_name + "&amp;nbsp;" + middle_name + "&amp;nbsp;" + last_name + "&lt;/td&gt;" + "&lt;td&gt;" + mobile + "&lt;/td&gt;" + "&lt;td&gt;" + created_on + "&lt;/td&gt;" + "&lt;td&gt;&lt;input type='checkbox' name='check[]'" + disabled + "value= '" + id + "' class='checkbox' id='select_all' &gt;&lt;/td&gt;" + "&lt;input type='hidden' value='" + id + "' name='user_id' id='user_id' &gt;" + "&lt;/tr&gt;" ; $("#datashow").append(tr_str); } } } ); } ); &lt;/script&gt; &lt;script&gt; $(function() { $('input[name="check[]"]').click(function() { var checkedChbx = $('[type=checkbox]:checked'); if (checkedChbx.length &gt; 0) { $('#one').show(); } else { $('#one').hide(); } }); }); $(document).ready(function() { var $submit = $("#one"); $submit.hide(); var $cbs = $('input[name="all_check[]"]').click(function() { $('input[name="check[]"]').prop('checked',$(this).is(":checked")); $submit.toggle($(this).is(":checked")); //use this to get the current clicked element }); }); &lt;/script&gt; &lt;script type="text/javascript"&gt; var select_all = document.getElementById("select_all"); //select all checkbox var checkboxes = document.getElementsByClassName("checkbox"); //checkbox items //select all checkboxes select_all.addEventListener("change", function(e){ for (i = 0; i &lt; checkboxes.length; i++) { checkboxes[i].checked = select_all.checked; } }); for (var i = 0; i &lt; checkboxes.length; i++) { checkboxes[i].addEventListener('change', function(e){ //".checkbox" change //uncheck "select all", if one of the listed checkbox item is unchecked if(this.checked == false){ select_all.checked = false; } //check "select all" if all checkbox items are checked if(document.querySelectorAll('.checkbox:checked').length == checkboxes.length){ select_all.checked = true; } }); } &lt;/script&gt; &lt;script&gt; // set users via PHP var users = "&lt;?php if (isset($_POST['users'])) echo $_POST['users']; ?&gt;"; // update the HTML without interfering with other scripts (function(users){ // check if PH if (users.length) { // update the radio option... var inputTag = document.querySelector('input[value="'+users+'"]'); if (inputTag) inputTag.checked = true; // if users is "all" // hide the last TD of every column if (users == "all") { var lastTh = document.querySelector('tr th:last-child'); lastTh.style.display = "none"; var allLastTds = document.querySelectorAll('td:last-child'); for (var i = 0; i&lt; allLastTds.length; i++) { allLastTds[i].style.display="none"; } } if (users == "approved") { thInputTag = document.getElementById("select_all"); thInputTag.setAttribute("disabled", true); } var form = document.querySelector("form"); var inputName = document.querySelectorAll('input[name="users"]'); for (var j=0; j&lt;inputName.length; j++) inputName[j].onclick=function(){ form.submit(); }; } })(users); &lt;/script&gt; </code></pre> <p><strong>report_ajax.php</strong></p> <pre><code>&lt;?php session_start(); require("../includes/config.php"); require("../classes/Database.class.php"); $db = new Database(DB_SERVER, DB_USER, DB_PASS, DB_DATABASE); $return_arr = array(); $status=''; if($_SERVER['REQUEST_METHOD'] == 'POST') { $value = filter_input(INPUT_POST, "selected_value"); if (isset($value)) { $users = $value; } else { $users=''; } switch ($users) { case "all": $sqlQuery = "SELECT * FROM tbl_user WHERE type =3"; break; case "approved": $sqlQuery = "SELECT * FROM tbl_user WHERE type =3 AND status =1"; break; } $sq = $db-&gt;query($sqlQuery); if ($db-&gt;affected_rows &gt; 0) { while ($row = mysql_fetch_array($sq)) { $disabled = ''; if ($status == '1') { $disabled = "disabled = 'disabled' checked='checked' "; } $id = $row['id']; $email = $row['email']; $employee_id = $row['employee_id']; $first_name = $row['first_name']; $middle_name = $row['middle_name']; $last_name = $row['last_name']; $mobile = $row['mobile']; $created_on1 = $row['created_on']; $created_on = date("d-m-Y", strtotime($created_on1)); $return_arr[] = array("id" =&gt; $id, "email" =&gt; $email, "employee_id" =&gt; $employee_id, "first_name" =&gt; $first_name, "middle_name" =&gt; $middle_name, "last_name" =&gt; $last_name, "mobile" =&gt; $mobile, "created_on" =&gt; $created_on "disabled" =&gt; $disabled ); } } header('Content-Type: application/json', true, 200); echo json_encode($return_arr); } </code></pre> </div>

使用PHP数据库Ajax时弹出框无法打开

<div class="post-text" itemprop="text"> <p>I am using this PHP Database Ajax code by <a href="https://www.w3schools.com/php/php_ajax_database.asp" rel="nofollow noreferrer">W3Schools.com</a></p> <p>This is my code, inside the PHP File (as shown in w3schools). It is working in this snippet. Also working, when i use this in the HTML file (as shown in w3schools).</p> <p>But when, i use this code in the PHP File, it is not working. What could possibly go wrong?</p> <p></p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-css lang-css prettyprint-override"><code>.playtrailer { background-color:#f2f2f2; color:red; font-weight:600; border:none; padding:10px 12px; } .playtrailer:hover { cursor:pointer; background-color:#e2e2e2; } #trailerdivbox { display:none; width:100%; height:100%; position:fixed; top:0%;overflow:auto; background-color:rgb(0, 0, 0); background-color:rgba(0, 0, 0, 0.4); } .videoWrapper { position:relative; padding-bottom:56.25%; padding-top:25px; margin:auto; height:0;top:100px; } .videoWrapper iframe { position:absolute; max-width:560px; max-height:315px; width:95%; height:95%; left:0; right:0; margin:auto; }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code> &lt;button id="playtrailer" class="playtrailer" data-src="naQr0uTrH_s"&gt; Play Trailer &amp;#9658; &lt;/button&gt; &lt;button id="playtrailer" class="playtrailer" data-src="naaQr0uTrH_s"&gt; Play Trailer &amp;#9658; &lt;/button&gt; &lt;!-- Watch Video Pop-up box --&gt; &lt;div id='close'&gt; &lt;div id='trailerdivbox'&gt; &lt;div class='videoWrapper'&gt; &lt;iframe id='video' class='trailervideo' width='560' height='315' data-src='https://www.youtube.com/embed/' src='about:blank' frameborder='0' allowfullscreen&gt;&lt;/iframe&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;!-- Script to open Pop-up box when someone click on watch video button --&gt; &lt;script&gt; // Get the modal var modal = document.getElementById('trailerdivbox'); // Get the button that opens the modal var btn = document.querySelectorAll('.playtrailer') function playVideo(src) { var video = document.getElementById('video'); video.src = 'https://www.youtube.com/embed/'+src + '?autoplay=1'; //add with iframe } function resetVideo() { var video = document.getElementById('video'); var src = video.src.replace('?autoplay=1', ''); video.src = ''; video.src = src; } // When the user clicks the button, open the modal btn.forEach(function(a){ a.onclick = function() { modal.style.display = "block"; playVideo(this.dataset.src); // pass the src } }) var trailerbox = document.getElementById("close"); trailerbox.onclick = function() { modal.style.display = "none"; resetVideo(); } // When the user clicks anywhere outside of the modal, close it window.onclick = function(event) { if (event.target == modal) { modal.style.display = "none"; resetVideo(); } } &lt;/script&gt;</code></pre> </div> </div> <p>Edit: This is my HTML file (Copy/pasted from w3schools)</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;script&gt; function showUser(str) { if (str == "") { document.getElementById("txtHint").innerHTML = ""; return; } else { if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp = new XMLHttpRequest(); } else { // code for IE6, IE5 xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange = function() { if (this.readyState == 4 &amp;&amp; this.status == 200) { document.getElementById("txtHint").innerHTML = this.responseText; } }; xmlhttp.open("GET","getuser.php?q="+str,true); xmlhttp.send(); } } &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;form&gt; &lt;select name="users" onchange="showUser(this.value)"&gt; &lt;option value=""&gt;Select a person:&lt;/option&gt; &lt;option value="1"&gt;Peter Griffin&lt;/option&gt; &lt;option value="2"&gt;Lois Griffin&lt;/option&gt; &lt;option value="3"&gt;Joseph Swanson&lt;/option&gt; &lt;option value="4"&gt;Glenn Quagmire&lt;/option&gt; &lt;/select&gt; &lt;/form&gt; &lt;br&gt; &lt;div id="txtHint"&gt;&lt;b&gt;Person info will be listed here...&lt;/b&gt;&lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>This is my PHP file (getuser.php)</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;style&gt; .playtrailer { background-color:#f2f2f2; color:red; font-weight:600; border:none; padding:10px 12px; } .playtrailer:hover { cursor:pointer; background-color:#e2e2e2; } #trailerdivbox { display:none; width:100%; height:100%; position:fixed; top:0%;overflow:auto; background-color:rgb(0, 0, 0); background-color:rgba(0, 0, 0, 0.4); } .videoWrapper { position:relative; padding-bottom:56.25%; padding-top:25px; margin:auto; height:0;top:100px; } .videoWrapper iframe { position:absolute; max-width:560px; max-height:315px; width:95%; height:95%; left:0; right:0; margin:auto; } &lt;/style&gt; &lt;/head&gt; &lt;body&gt; &lt;button id="playtrailer" class="playtrailer" data-src="naQr0uTrH_s"&gt; Play Trailer &amp;#9658; &lt;/button&gt; &lt;button id="playtrailer" class="playtrailer" data-src="naaQr0uTrH_s"&gt; Play Trailer &amp;#9658; &lt;/button&gt; &lt;!-- Watch Video Pop-up box --&gt; &lt;div id='close'&gt; &lt;div id='trailerdivbox'&gt; &lt;div class='videoWrapper'&gt; &lt;iframe id='video' class='trailervideo' width='560' height='315' data-src='https://www.youtube.com/embed/' src='about:blank' frameborder='0' allowfullscreen&gt;&lt;/iframe&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;!-- Script to open Pop-up box when someone click on watch video button --&gt; &lt;script&gt; // Get the modal var modal = document.getElementById('trailerdivbox'); // Get the button that opens the modal var btn = document.querySelectorAll('.playtrailer') function playVideo(src) { var video = document.getElementById('video'); video.src = 'https://www.youtube.com/embed/'+src + '?autoplay=1'; //add with iframe } function resetVideo() { var video = document.getElementById('video'); var src = video.src.replace('?autoplay=1', ''); video.src = ''; video.src = src; } // When the user clicks the button, open the modal btn.forEach(function(a){ a.onclick = function() { modal.style.display = "block"; playVideo(this.dataset.src); // pass the src } }) var trailerbox = document.getElementById("close"); trailerbox.onclick = function() { modal.style.display = "none"; resetVideo(); } // When the user clicks anywhere outside of the modal, close it window.onclick = function(event) { if (event.target == modal) { modal.style.display = "none"; resetVideo(); } } &lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> </div>

更改选择其他下拉列表时的下拉值

<div class="post-text" itemprop="text"> <p>Need experts opinion on below mentioned code, i am not good with javascript. please help</p> <p>what i need is,i have 2 drop downs. one is catid1 and 2nd is catid ... catid loads some values from databases, and catid1 have some manual entries, few of them are same and few are different. but i want is when i will select catid1 value from list like "abc" then catid value should be changed to same as catid1 "abc" i have tried some different ways but can't resolve this, any one please suggest either this could be possible or not. </p> <pre><code>&lt;div class="col-md-4"&gt; &lt;div class="form-group"&gt; &lt;label for="catId"&gt;&lt;?php echo $categoryField; ?&gt;&lt;/label&gt; &lt;select class="form-control" name="catId1" id="catId1" onChange="qt();"&gt; &lt;option&gt; Select Base Query Type &lt;/option&gt; &lt;/select&gt; &lt;span class="help-block"&gt;&lt;?php echo $categoryHelp; ?&gt;&lt;/span&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="col-md-4"&gt; &lt;div class="form-group"&gt; &lt;label for="catId"&gt;&lt;?php echo $categoryField; ?&gt;&lt;/label&gt; &lt;select class="form-control" name="catId" id="catId"&gt; &lt;?php $tcat = "SELECT catId, catName FROM categories WHERE userId = ".$userId." AND isActive = 1 "; $rest = mysqli_query($mysqli, $tcat) or die('-2'.mysqli_error()); ?&gt; &lt;option value="..."&gt;&lt;?php echo $selectOption; ?&gt;&lt;/option&gt; &lt;?php while ($tcatrow = mysqli_fetch_assoc($rest)) { ?&gt; &lt;option value="&lt;?php echo $tcatrow['catId']; ?&gt;"&gt;&lt;?php echo clean($tcatrow['catName']); ?&gt;&lt;/option&gt; &lt;?php } ?&gt; &lt;/select&gt; &lt;span class="help-block"&gt;&lt;?php echo $categoryHelp; ?&gt;&lt;/span&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>sample code which i have tried is as below as well but it's not working in my case.</p> <pre><code>&lt;select name="dropdown[]"&gt; &lt;option value="1"&gt;Sony&lt;/option&gt; &lt;option value="2"&gt;Nintendo&lt;/option&gt; &lt;option value="3"&gt;Microsoft&lt;/option&gt; &lt;/select&gt; &lt;select name="dropdown[]"&gt; &lt;option value="1"&gt;Sony&lt;/option&gt; &lt;option value="2"&gt;Nintendo&lt;/option&gt; &lt;option value="3"&gt;Microsoft&lt;/option&gt; &lt;/select&gt; &lt;select name="dropdown[]"&gt; &lt;option value="1"&gt;Sony&lt;/option&gt; &lt;option value="2"&gt;Nintendo&lt;/option&gt; &lt;option value="3"&gt;Microsoft&lt;/option&gt; &lt;/select&gt; var selects = document.querySelectorAll('select[name="dropdown[]"]'); selects[0].addEventListener('change', function () { for (var i = 0; i &lt; selects.length; i++) { selects[i].value = selects[0].value; } }); </code></pre> </div>

elenium自动化测试,使用By.cssSelector(cssSelector);定位不对。

自己搭建selenium自动化测试,在使用driver.findElements(By.cssSelector(cssSelector));这一句时出现报错。但是同样的路径,我用By.xPath就不会出问题。 org.openqa.selenium.InvalidElementStateException: invalid element state: Failed to execute 'querySelectorAll' on 'Document': '#paramValueTable div#60002_60002001_0 > select.textInput' is not a valid selector. (Session info: chrome=38.0.2125.122) (Driver info: chromedriver=2.9.248315,platform=Windows NT 6.1 x86) (WARNING: The server did not provide any stacktrace information) Command duration or timeout: 27 milliseconds Build info: version: '2.25.0', revision: '17482', time: '2012-07-18 21:09:54' System info: os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.7.0_79' Driver info: driver.version: RemoteWebDriver Session ID: 5a0458394ba8566a9fdd8a33e0b412f2 at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:526) at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:188) at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:145) at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:498) at org.openqa.selenium.remote.RemoteWebDriver.findElements(RemoteWebDriver.java:287) at org.openqa.selenium.remote.RemoteWebDriver.findElementsByCssSelector(RemoteWebDriver.java:349) at org.openqa.selenium.By$ByCssSelector.findElements(By.java:417) at org.openqa.selenium.remote.RemoteWebDriver.findElements(RemoteWebDriver.java:256) at comba.BaseTest.checkAllDiv(BaseTest.java:1189) at comba.BaseTest.test(BaseTest.java:343) at comba.BaseTest.<init>(BaseTest.java:173) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:526) at Runner.test(Runner.java:344) at Runner.run(Runner.java:252) at Runner.runMain(Runner.java:203) at Runner.main(Runner.java:176)

在选中的复选框上显示编辑按钮

<div class="post-text" itemprop="text"> <p>I have an HTML <code>Table</code> with the last column being a column with <code>checkboxes</code>. I want it be so that whenever I check the <code>checkbox</code>, an edit button pops up right next to the table and allows me to edit that row. </p> <p>Right now, on load, the edit button is already there and when a checkbox is checked, it does nothing. </p> <p>How can I fix this?</p> <p>HTML/PHP code:</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;title&gt;Stage Rebate Master HTML Table&lt;/title&gt; &lt;link rel="stylesheet" type="text/css" href="html_master.css"&gt; &lt;script type="text/javascript" src=jquery-1.8.3.js&gt;&lt;/script&gt; &lt;script src="html_master.js"&gt;&lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;table id="html_master"&gt; &lt;thead&gt; &lt;tr&gt; &lt;td&gt;MR_ID&lt;/td&gt; &lt;td&gt;MR_Name&lt;/td&gt; &lt;td&gt;Buyer_ID&lt;/td&gt; &lt;td&gt;MR_POC_N&lt;/td&gt; &lt;td&gt;MR_POC_E&lt;/td&gt; &lt;td&gt;MR_POC_P&lt;/td&gt; &lt;td&gt;Select&lt;/td&gt; &lt;/tr&gt; &lt;/thead&gt; &lt;tbody&gt; &lt;?php foreach ($dbh-&gt;query($sql) as $rows){ ?&gt; &lt;tr&gt; &lt;td id="mr_id"&gt;&lt;?php echo intval ($rows['MR_ID'])?&gt;&lt;/td&gt; &lt;td id="mr_name"&gt;&lt;?php echo $rows['MR_Name']?&gt;&lt;/td&gt; &lt;td id="buyer_id"&gt;&lt;?php echo $rows['Buyer_ID']?&gt;&lt;/td&gt; &lt;td id="poc_n"&gt;&lt;?php echo $rows['MR_POC_N']?&gt;&lt;/td&gt; &lt;td id="poc_e"&gt;&lt;?php echo $rows['MR_POC_E']?&gt;&lt;/td&gt; &lt;td id="poc_p"&gt;&lt;?php echo $rows['MR_POC_P']?&gt;&lt;/td&gt; &lt;td align="center"&gt;&lt;input type="checkbox" name="check" value="checked"&gt;&lt;/td&gt; &lt;/tr&gt; &lt;?php } ?&gt; &lt;/tbody&gt; &lt;input type="button" class="add" value="Add Row" onclick="addRow('html_master')"&gt; &lt;input type="button" id="edit" value="Edit" name="edit"&gt; &lt;input type="button" id="delRow" value="Delete" onclick="deleteRow('html_master')"&gt; &lt;/table&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>Relative Javascript:</p> <pre><code> // ----- Delete Row ----- function deleteRow(html_master){ var tbl=document.getElementById(html_master); var col=tbl.querySelectorAll('input[type=\"checkbox\"]:checked'); if( col ){ for( var n in col )if( col[ n ].nodeType==1 ){ try { var tr=col[ n ].parentNode.parentNode; var tbody=tr.parentNode; tbody.removeChild( tr ); }catch( err ){ console.warn(err); continue; } } } } // ----- Add Row ----- function addRow(tableID) { var table = document.getElementById(tableID); var rowCount = table.rows.length; var row = table.insertRow(rowCount); var cell1 = row.insertCell(0); cell1.innerHTML = rowCount; var cell2 = row.insertCell(1); var element2 = document.createElement("input"); element2.type = "text"; element2.name = "txtbox[]"; cell2.appendChild(element2); var cell3 = row.insertCell(2); var element3 = document.createElement("input"); element3.type = "text"; element3.name = "txtbox[]"; cell3.appendChild(element3); var cell4 = row.insertCell(3); var element4 = document.createElement("input"); element4.type = "text"; element4.name = "txtbox[]"; cell4.appendChild(element4); var cell5 = row.insertCell(4); var element5 = document.createElement("input"); element5.type = "text"; element5.name = "txtbox[]"; cell5.appendChild(element5); var cell6 = row.insertCell(5); var element6 = document.createElement("input"); element6.type = "text"; element6.name = "txtbox[]"; cell6.appendChild(element6); var cell7 = row.insertCell(6); var element7 = document.createElement("input"); element7.type = "checkbox"; element7.name="chkbox[]"; cell7.appendChild(element7); } $(document).ready(function() { var $submit = $("#edit").hide(), $cbs = $('input[name="check"]').click(function() { $submit.toggle($cbs.is(":checked")); }); }); </code></pre> <p>DB Code:</p> <pre><code>&lt;?php $host="xxxxxx"; $dbName="xxxxxxx"; $dbUser="xxxxx"; $dbPass="xxxxxxxxxxxx"; $dbh = new PDO( "sqlsrv:server=".$host."; Database=".$dbName, $dbUser, $dbPass); $dbh-&gt;setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION ); $sql = "SELECT * FROM Stage_Rebate_Master ORDER BY MR_ID ASC"; ?&gt; </code></pre> <p>CSS code:</p> <pre><code>body { background-image: url("background.png"); } table { border-collapse: collapse; } td { border: 1.5px solid black; padding: 3px; } thead { font-weight: bold; } </code></pre> </div>

试图结合两个Java脚本但相互干扰(jQuery-Tabledit和Multi filter)代码有什么问题

<div class="post-text" itemprop="text"> <p>I'm trying to combine tow jQuery-Tabledit and Multi filter (<a href="https://stackoverflow.com/questions/31672909/multi-filterable-table-with-js/31673308#31673308">Multi-Filterable Table with JS</a>)</p> <p>till 3rd column, the code is working fine but after that jQuery-Tabledit replace search box with an input field.</p> <p>how can I prevent this</p> <p>I found a few answers for Two jquery tools interfere with each other but they are completely different from the issue I'm facing</p> <p>I also tried loading the script one by one but I Cant load the function one by one as both scripts work actively on a page</p> <p>Posting full code because i have no idea what part of the code creating the issue </p> <pre><code>&lt;?php session_start(); ?&gt; &lt;?php if(isset($_SESSION['valids'])) { ?&gt; &lt;?php } else { header("Location: http://XXX.XX.XX.XXX/superuser/login.php"); } ?&gt; &lt;?php include('db-connect.php'); $sql = "SELECT TeamName FROM superuser WHERE id = '".$_SESSION['id']."'"; $valueToSearch3 = mysqli_query($con, $sql) or die("error to fetch employees data"); while ($row222 = $valueToSearch3-&gt;fetch_assoc()) if(isset($_POST['search'])) { $valueToSearch = $_POST['valueToSearch']; $sql = "SELECT * FROM `attendance` WHERE date = '".$valueToSearch."' and TeamName LIKE '".$row222['TeamName']."'"; $row1 = mysqli_query($con, $sql) or die("error to fetch employees data"); } else { $sql = "SELECT * FROM `attendance` WHERE date = CURDATE() and TeamName LIKE '%".$row222['TeamName']."%'"; $row1 = mysqli_query($con, $sql) or die("error to fetch employees data"); } ?&gt; &lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;link rel="stylesheet" href="bootstrap.min.css"&gt; &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"&gt;&lt;/script&gt; &lt;script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"&gt;&lt;/script&gt; &lt;script src="jquery.tabledit.js"&gt;&lt;/script&gt; &lt;/head&gt; &lt;script type="text/javascript"&gt; $(document).ready(function(){ $('#example1').Tabledit({ url: 'logic-edit-delete.php', editButton: false, deleteButton: false, hideIdentifier: true, columns: { identifier: [0, 'id'], editable: [[4, 'Status', '{"-": "Select","P": "Present", "PL": "Planed Leave", "UPL": "UnPlaned Leave", "WO": "Week Off", "COff": "Comp Off", "PH": "Public Holiday", "UPHD": "UnPlaned Half Day", "PHD": "Planed Half Day", "LWP": "Leave Without Pay"}'], [5, 'Leavetype', '{"-": "Select","Sick Leave": "Sick Leave", "Casual Leave": "Casual Leave", "Exigencies": "Exigencies"}']] }, onDraw: function() { console.log('onDraw()'); }, onSuccess: function(data, textStatus, jqXHR) { console.log('onSuccess(data, textStatus, jqXHR)'); console.log(data); console.log(textStatus); console.log(jqXHR); }, onFail: function(jqXHR, textStatus, errorThrown) { console.log('onFail(jqXHR, textStatus, errorThrown)'); console.log(jqXHR); console.log(textStatus); console.log(errorThrown); }, onAlways: function() { console.log('onAlways()'); }, onAjax: function(action, serialize) { console.log('onAjax(action, serialize)'); console.log(action); console.log(serialize); } }); }); &lt;/script&gt; &lt;style&gt; .table.user-select-none { -webkit-touch-callout: none; -webkit-user-select: none; -khtml-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; } &lt;/style&gt; &lt;/head&gt; &lt;link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css"&gt; &lt;link rel="stylesheet" href="/resources/demos/style.css"&gt; &lt;script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"&gt;&lt;/script&gt; &lt;body&gt; &lt;div class="container" style="margin-top:10px;"&gt; &lt;div class="panel panel-default"&gt; &lt;div class="panel-heading"&gt; &lt;form action="indexFilter.php" method="post"&gt; &lt;button&gt;&lt;a href="http://XXX.XX.XX.XXX/superuser/"&gt;Home&lt;/a&gt;&lt;/button&gt; &lt;button&gt;&lt;a href="http://XXX.XX.XX.XXX/"&gt;Add a new &lt;/a&gt;&lt;/button&gt; &lt;button&gt;&lt;a href="http://XXX.XX.XX.XXX/superuser/logout.php"&gt;Logout&lt;/a&gt;&lt;/button&gt; &lt;b&gt;Selact Date&lt;/b&gt; &lt;input type="text" id="Datetos" name="valueToSearch" /&gt; &lt;script type="text/javascript"&gt; $('#Datetos').datepicker({ dateFormat: 'yy-mm-dd' }); &lt;/script&gt; &lt;script type="text/javascript"&gt; function filter(_id) { var table = document.getElementById(_id); //get all filters. var getFilters = [table.querySelectorAll("input")[0].value.toLowerCase(), table.querySelectorAll("input")[1].value.toLowerCase(), table.querySelectorAll("input")[2].value.toLowerCase(), table.querySelectorAll("input")[3].value.toLowerCase(), table.querySelectorAll("input")[4].value.toLowerCase()] for (var r = 2; r &lt; table.rows.length; r++) { //strip tags var el1 = table.rows[r].cells[0].innerHTML.replace(/&lt;[^&gt;]+&gt;/g, ""); var el2 = table.rows[r].cells[1].innerHTML.replace(/&lt;[^&gt;]+&gt;/g, ""); var el3 = table.rows[r].cells[2].innerHTML.replace(/&lt;[^&gt;]+&gt;/g, ""); var el4 = table.rows[r].cells[3].innerHTML.replace(/&lt;[^&gt;]+&gt;/g, ""); var el5 = table.rows[r].cells[4].innerHTML.replace(/&lt;[^&gt;]+&gt;/g, ""); var search1 = el1.toLowerCase().indexOf(getFilters[0]); var search2 = el2.toLowerCase().indexOf(getFilters[1]); var search3 = el3.toLowerCase().indexOf(getFilters[2]); var search4 = el4.toLowerCase().indexOf(getFilters[3]); var search5 = el5.toLowerCase().indexOf(getFilters[4]); //test all searches, if found or el = empty display if ( (search1 &gt;= 0 || el1 == "" ) &amp;&amp; (search2 &gt;= 0 || el2 == "" ) &amp;&amp; (search3 &gt;= 0 || el3 == "" ) &amp;&amp; (search4 &gt;= 0 || el4 == "" ) &amp;&amp; (search5 &gt;= 0 || el5 == "" )) { table.rows[r].style.display = ''; } else { table.rows[r].style.display = 'none'; } } } &lt;/script&gt; &lt;input type="submit" name="search" value="Filter"&gt; &lt;button&gt;&lt;a href="http://XXX.XX.XX.XXX/superuser/Attendance/"&gt;Reload&lt;/a&gt;&lt;/button&gt; &lt;/form&gt; &lt;/div&gt; &lt;div class="panel-body"&gt; &lt;table class="table" id="example1" style="border:1px solide red"&gt; &lt;tr&gt; &lt;td&gt;&lt;input placeholder="search" name="filterinput3" onkeyup="filter('example1')" type="text" size="3"&gt;&lt;/input&gt;&lt;/td&gt; &lt;td&gt;&lt;input placeholder="search" name="filterinput3" onkeyup="filter('example1')" type="text" size="3"&gt;&lt;/input&gt;&lt;/td&gt; &lt;td&gt;&lt;input placeholder="search" name="filterinput3" onkeyup="filter('example1')" type="text" size="3"&gt;&lt;/input&gt;&lt;/td&gt; &lt;td&gt;&lt;input placeholder="search" name="filterinput3" onkeyup="filter('example1')" type="text" size="3"&gt;&lt;/input&gt;&lt;/td&gt; &lt;td&gt;&lt;input placeholder="search" name="filterinput3" onkeyup="filter('example1')" type="text" size="3"&gt;&lt;/input&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt;&lt;th&gt;ID&lt;/th&gt;&lt;th&gt;Date&lt;/th&gt;&lt;th&gt;EmpID&lt;/th&gt;&lt;th&gt;Name&lt;/th&gt;&lt;th&gt;Status&lt;/th&gt;&lt;th&gt;Leave Type&lt;/th&gt;&lt;th&gt;Shift&lt;/th&gt;&lt;th&gt;Team Name&lt;/th&gt;&lt;/tr&gt; &lt;?php while($row = mysqli_fetch_assoc($row1)) {?&gt; &lt;tr&gt; &lt;td&gt;&lt;?php echo $row['id'];?&gt;&lt;/td&gt; &lt;td&gt;&lt;?php echo $row['Date']; ?&gt;&lt;/td&gt; &lt;td&gt;&lt;?php echo $row['EmpID']; ?&gt;&lt;/td&gt; &lt;td&gt;&lt;?php echo $row['name']; ?&gt;&lt;/td&gt; &lt;td&gt;&lt;?php echo $row['Status']; ?&gt;&lt;/td&gt; &lt;td&gt;&lt;?php echo $row['Leavetype']; ?&gt;&lt;/td&gt; &lt;td&gt;&lt;?php echo $row['Shift']; ?&gt;&lt;/td&gt; &lt;td&gt;&lt;?php echo $row['TeamName']; ?&gt;&lt;/td&gt; &lt;/tr&gt; &lt;?php } ?&gt; &lt;/table&gt; &lt;/div&gt; &lt;script type="text/javascript"&gt; $('table tr td:nth-child(5)').each(function () { $(this).text() == 'P' &amp;&amp; $(this).parent().find('td:nth-child(5)').css('background-color', '#bcfba3'); }); $('table tr td:nth-child(5)').each(function () { $(this).text() == 'P' &amp;&amp; $(this).parent().find('td:nth-child(3)').css('background-color', '#bcfba3'); }); &lt;/script&gt; &lt;/div&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> </div>

为什么这个日期会导致错误?

<div class="post-text" itemprop="text"> <p>So not so long ago I made my own booking system which displays a calendar on a page with the dates that have been booked but I noticed recently, if one of the bookings goes across two months e.g. 29th March to 4th April the whole thing just crashes / doesn't load and I'm really confused as to why. The date still gets entered into my database but then it breaks.</p> <p>Here is the code for displaying the calendar (<strong>Note:</strong> I got most of this code from a CodePen and edited it accordingly):</p> <pre><code>&lt;?php session_start(); ob_start(); $host = "myhostname"; // Host name $username = "myusername"; // Mysql username $password = ""; // Mysql password $db_name = "mydatabase"; // Database name $tbl_name = "booking"; // Table name // Connect to server and select databse. $conn = mysqli_connect($host, $username, $password)or die("cannot connect"); mysqli_select_db($conn, $db_name)or die("cannot select DB"); $sql = "SELECT * FROM $tbl_name"; $result = mysqli_query($conn, $sql); ?&gt; &lt;script&gt; !function() { var today = moment(); function Calendar(selector, events) { this.el = document.querySelector(selector); this.events = events; this.current = moment().date(1); this.events.forEach(function(ev) { ev.date = moment(ev.date); }); this.draw(); var current = document.querySelector('.today'); if(current) { var self = this; window.setTimeout(function() { self.openDay(current); }, 500); } } Calendar.prototype.draw = function() { //Create Header this.drawHeader(); //Draw Month this.drawMonth(); } Calendar.prototype.drawHeader = function() { var self = this; if(!this.header) { //Create the header elements this.header = createElement('div', 'header'); this.header.className = 'header'; this.title = createElement('h3'); var right = createElement('div', 'right'); right.addEventListener('click', function() { self.nextMonth(); }); var left = createElement('div', 'left'); left.addEventListener('click', function() { self.prevMonth(); }); document.addEventListener("keydown", function(event) { if (event.keyCode === 39) { event.preventDefault(); self.nextMonth(); } else if (event.keyCode === 37) { event.preventDefault(); self.prevMonth(); } }); //Append the Elements this.header.appendChild(this.title); this.header.appendChild(right); this.header.appendChild(left); this.el.appendChild(this.header); } this.title.innerHTML = this.current.format('MMMM YYYY'); } Calendar.prototype.drawMonth = function() { var self = this; if(this.month) { this.oldMonth = this.month; this.oldMonth.className = 'month out ' + (self.next ? 'next' : 'prev'); this.oldMonth.addEventListener('webkitAnimationEnd', function() { self.oldMonth.parentNode.removeChild(self.oldMonth); self.month = createElement('div', 'month'); self.backFill(); self.currentMonth(); self.fowardFill(); self.el.appendChild(self.month); window.setTimeout(function() { self.month.className = 'month in ' + (self.next ? 'next' : 'prev'); }, 16); }); } else { this.month = createElement('div', 'month'); this.el.appendChild(this.month); this.backFill(); this.currentMonth(); this.fowardFill(); this.month.className = 'month new'; } } Calendar.prototype.backFill = function() { var clone = this.current.clone(); var dayOfWeek = clone.day(); if(!dayOfWeek) { return; } clone.subtract('days', dayOfWeek); for(var i = dayOfWeek; i &gt; 1 ; i--) { this.drawDay(clone.add('days', 1)); } } Calendar.prototype.fowardFill = function() { var clone = this.current.clone().add('months', 1).subtract('days', 1); var dayOfWeek = clone.day(); if(dayOfWeek === 7) { return; } for(var i = dayOfWeek; i &lt; 7 ; i++) { this.drawDay(clone.add('days', 1)); } } Calendar.prototype.currentMonth = function() { var clone = this.current.clone(); while(clone.month() === this.current.month()) { this.drawDay(clone); clone.add('days', 1); } } Calendar.prototype.getWeek = function(day) { if(!this.week || day.day() === 1) { this.week = createElement('div', 'week'); this.month.appendChild(this.week); } } Calendar.prototype.drawDay = function(day) { var self = this; this.getWeek(day); //Outer Day var outer = createElement('div', this.getDayClass(day)); outer.addEventListener('click', function() { self.openDay(this); }); //Day Name var name = createElement('div', 'day-name', day.format('ddd')); //Day Number var number = createElement('div', 'day-number', day.format('DD')); //Events var events = createElement('div', 'day-events'); this.drawEvents(day, events); outer.appendChild(name); outer.appendChild(number); outer.appendChild(events); this.week.appendChild(outer); } Calendar.prototype.drawEvents = function(day, element) { if(day.month() === this.current.month()) { var todaysEvents = this.events.reduce(function(memo, ev) { if(ev.date.isSame(day, 'day')) { memo.push(ev); } return memo; }, []); todaysEvents.forEach(function(ev) { var evSpan = createElement('span', ev.color); element.appendChild(evSpan); }); } } Calendar.prototype.getDayClass = function(day) { classes = ['day']; if(day.month() !== this.current.month()) { classes.push('other'); } else if (today.isSame(day, 'day')) { classes.push('today'); } return classes.join(' '); } Calendar.prototype.openDay = function(el) { var details, arrow; var dayNumber = +el.querySelectorAll('.day-number')[0].innerText || +el.querySelectorAll('.day-number')[0].textContent; var day = this.current.clone().date(dayNumber); var currentOpened = document.querySelector('.details'); //Check to see if there is an open detais box on the current row if(currentOpened &amp;&amp; currentOpened.parentNode === el.parentNode) { details = currentOpened; arrow = document.querySelector('.arrow'); } else { //Close the open events on differnt week row //currentOpened &amp;&amp; currentOpened.parentNode.removeChild(currentOpened); if(currentOpened) { currentOpened.addEventListener('webkitAnimationEnd', function() { currentOpened.parentNode.removeChild(currentOpened); }); currentOpened.addEventListener('oanimationend', function() { currentOpened.parentNode.removeChild(currentOpened); }); currentOpened.addEventListener('msAnimationEnd', function() { currentOpened.parentNode.removeChild(currentOpened); }); currentOpened.addEventListener('animationend', function() { currentOpened.parentNode.removeChild(currentOpened); }); currentOpened.className = 'details out'; } //Create the Details Container details = createElement('div', 'details in'); //Create the arrow var arrow = createElement('div', 'arrow'); //Create the event wrapper details.appendChild(arrow); el.parentNode.appendChild(details); } var todaysEvents = this.events.reduce(function(memo, ev) { if(ev.date.isSame(day, 'day')) { memo.push(ev); } return memo; }, []); this.renderEvents(todaysEvents, details); arrow.style.left = el.offsetLeft - el.parentNode.offsetLeft + 27 + 'px'; } Calendar.prototype.renderEvents = function(events, ele) { //Remove any events in the current details element var currentWrapper = ele.querySelector('.events'); var wrapper = createElement('div', 'events in' + (currentWrapper ? ' new' : '')); events.forEach(function(ev) { var div = createElement('div', 'event'); var span = createElement('span', '', ev.eventName); div.appendChild(span); wrapper.appendChild(div); }); if(!events.length) { var div = createElement('div', 'event empty'); var span = createElement('span', '', 'No Booking'); div.appendChild(span); wrapper.appendChild(div); } if(currentWrapper) { currentWrapper.className = 'events out'; currentWrapper.addEventListener('webkitAnimationEnd', function() { currentWrapper.parentNode.removeChild(currentWrapper); ele.appendChild(wrapper); }); currentWrapper.addEventListener('oanimationend', function() { currentWrapper.parentNode.removeChild(currentWrapper); ele.appendChild(wrapper); }); currentWrapper.addEventListener('msAnimationEnd', function() { currentWrapper.parentNode.removeChild(currentWrapper); ele.appendChild(wrapper); }); currentWrapper.addEventListener('animationend', function() { currentWrapper.parentNode.removeChild(currentWrapper); ele.appendChild(wrapper); }); } else { ele.appendChild(wrapper); } } Calendar.prototype.drawLegend = function() { var calendars = this.events.map(function(e) { return e.calendar + '|' + e.color; }).reduce(function(memo, e) { if(memo.indexOf(e) === -1) { memo.push(e); } return memo; }, []).forEach(function(e) { var parts = e.split('|'); var entry = createElement('span', 'entry ' + parts[1], parts[0]); }); } Calendar.prototype.nextMonth = function() { this.current.add('months', 1); this.next = true; this.draw(); } Calendar.prototype.prevMonth = function() { this.current.subtract('months', 1); this.next = false; this.draw(); } window.Calendar = Calendar; function createElement(tagName, className, innerText) { var ele = document.createElement(tagName); if(className) { ele.className = className; } if(innerText) { ele.innderText = ele.textContent = innerText; } return ele; } }(); !function() { var data = [ &lt;?php $colour = 'blue'; while($rows = mysqli_fetch_array($result)) { if($rows['status'] == 'Confirmed') { $colour = 'red'; } else { $colour = 'blue'; } ?&gt; { eventName: 'Booking Start', calendar: 'Booking &lt;?php echo $rows['status']; ?&gt;', color: '&lt;?php echo $colour; ?&gt;', date: '&lt;?php echo $rows['arrive_date']?&gt;'}, &lt;?php $date = date('Y-m-d', strtotime($rows['arrive_date'])); while ($date &lt; date('Y-m-d', strtotime($rows['depart_date']. '-1 day'))) { $date++; ?&gt; { eventName: 'Booked', calendar: 'Booking &lt;?php echo $rows['status']; ?&gt;', color: '&lt;?php echo $colour; ?&gt;', date: '&lt;?php echo $date;?&gt;'}, &lt;?php } ?&gt; { eventName: 'Booking End', calendar: 'Booking &lt;?php echo $rows['status']; ?&gt;', color: '&lt;?php echo $colour; ?&gt;', date: '&lt;?php echo $rows['depart_date']; ?&gt;'}, &lt;?php } ?&gt; ]; var calendar = new Calendar('#calendar', data); }(); &lt;/script&gt; </code></pre> <p><strong>EDIT:</strong> In case you need further help this is what an example looks like from the table in the database: <a href="https://i.stack.imgur.com/GYRr4.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/GYRr4.png" alt="Table example"></a></p> <p>I can't work out what is causing this problem, I believe it is something to do with the events but I don't know. I was hoping someone a little more experienced could help me out a little.</p> <p>To see what it looks like visually you can see it live here: <a href="https://ryan-simms.com/booking/bookings" rel="nofollow noreferrer">https://ryan-simms.com/booking/bookings</a></p> <p><strong>EDIT:</strong> I just found out, doing a test, that if I put in 28th February to the 1st March it doesn't crash but if I change it so it ends on the 2nd March it crashes, really odd.</p> </div>

如何将所有下拉菜单的值更改为所选的选项?

<div class="post-text" itemprop="text"> <p>I am having difficulty figuring out a JavaScript function. I would like for all drop down menus below the selected value to change to that value.</p> <p>Here is an example of what I want the drop down menus to do:</p> <p>If I change the value of id 3 in Primer Source to "To Be Saved", then I want all the other drop down menus to change to that value.</p> <p><a href="https://i.stack.imgur.com/lgZRm.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/lgZRm.png" alt="enter image description here"></a></p> <p>I believe I will need a JavaScript function so I made one called <code>changeNote</code> which is called in the onChange of my <code>&lt;select&gt;</code> tag. </p> <p>Here is my table: </p> <pre><code>&lt;input type="hidden" id="primerSource_s&lt;?=$i;?&gt;" name="primerSource_s[&lt;?=$i;?&gt;]" value="&lt;?=$abbNotes?&gt;" class="primerSource" /&gt; &lt;select name="primerSource&lt;?php echo $SampleID; ?&gt;" id="primerSource&lt;?php echo $SampleID; ?&gt;" &lt;?php echo $CSS_display0; ?&gt; value onChange='changeNote(this);' &gt; &lt;option value="" &gt;Please Select&lt;/option&gt; &lt;option value="Premixed" &lt;?php if ("Premixed" == $_POST['primerSource' . $SampleID]) { echo " selected = 'selected' "; } elseif (($_POST['primerSource' . $SampleID] == '') &amp;&amp; ("Premixed" == $abbNotes)) { echo " selected = 'selected' ";} ?&gt; &gt;Premixed &lt;/option&gt; &lt;option value="To Be Saved" &lt;?php if ("To Be Saved" == $_POST['primerSource' . $SampleID]) { echo " selected = 'selected' "; } elseif (($_POST['primerSource' . $SampleID] == '') &amp;&amp; ("To Be Saved" == $abbNotes)) { echo " selected = 'selected' ";} ?&gt; &gt;To Be Saved &lt;/option&gt; &lt;option value="Providing Primer" &lt;?php if ("Providing Primer" == $_POST['primerSource' . $SampleID]) { echo " selected = 'selected' "; } elseif (($_POST['primerSource' . $SampleID] == '') &amp;&amp; ("Providing Primer" == $abbNotes)) { echo " selected = 'selected' ";} ?&gt; &gt;Providing Primer &lt;/option&gt; &lt;option value="Saved Primer(Eton)" &lt;?php if ("Saved Primer(Eton)" == $_POST['primerSource' . $SampleID]) { echo " selected = 'selected' "; } elseif (($_POST['primerSource' . $SampleID] == '') &amp;&amp; ("Saved Primer(Eton)" == $abbNotes)) { echo " selected = 'selected' ";} ?&gt; &gt;Saved Primer(Eton) &lt;/option&gt; &lt;option value="Eton Universal Primer" &lt;?php if ("Eton Universal Primer" == $_POST['primerSource' . $SampleID]) { echo " selected = 'selected' "; } elseif (($_POST['primerSource' . $SampleID] == '') &amp;&amp; ("Eton Universal Primer" == $abbNotes)) { echo " selected = 'selected' ";} ?&gt; &gt;Eton Universal Primer &lt;/option&gt; &lt;option value="To Be Synthesized By Eton" &lt;?php if ("To Be Synthesized By Eton" == $_POST['primerSource' . $SampleID]) { echo " selected = 'selected' "; } elseif (($_POST['primerSource' . $SampleID] == '') &amp;&amp; ("To Be Synthesized By Eton" == $abbNotes)) { echo " selected = 'selected' ";} ?&gt; &gt;To Be Synthesized By Eton &lt;/option&gt; &lt;/select&gt; </code></pre> <p>I made this changeNote function, but I went through code from other parts of the website that did what I was asking for. I am not sure why it is not working.</p> <pre><code>function changeNote(myselectbox){ var value = myselectbox.value; var elements = document.querySelectorAll('.SampleName'); var index = parseInt(myselectbox.id.match(/\d+$/)); var filled_rows = 0; for( var a = 0, l = elements.length; a &lt; l; a++ ) { if( document.getElementById('.SampleName'+a).value != "") { filled_rows++ console.log(`filled rows: ${filled_rows}`) } } if(value=="Synthesize"){ $("#check_space"+index).css("display","block"); $("#hasOligo"+index).attr("value",true); $("#hasOligo"+index).attr("checked",true); $("#hasOligo_"+index).attr("value",true); $("#PrimerCntr"+index).attr("value",""); $("#PrimerCntr_t"+index).attr("value",""); $("#PrimerCntr_t"+index).prop("disabled",true); $("#GlobalPrimerCntr"+index).val(""); $("#GlobalPrimerCntr"+index).prop("disabled",true); $("#Notes_s"+index).val("Synthesize"); $("#Notes"+index).attr("value","Synthesize"); $("#Notes_s"+index).prop("disabled",true); $("#primerSource"+index).val("Synthesize"); $("#primerSource_s"+index).attr("value","Synthesize"); $("#primerSource"+index).prop("disabled",true); console.log('this is working') }else{ for( var i = index; i &lt; filled_rows; i++ ) { if(document.getElementById('primerSource'+i).value != "" &amp;&amp; document.getElementById('primerSource'+i).hasAttribute("disabled")==false){ document.getElementById('primerSource_s'+i).value = value; document.getElementById('primerSource'+i).value = value; console.log('primer is working') } } console.log('else is working') } </code></pre> <p>}</p> <p>Please help me figure out how to make that function! I am not sure if my logic makes sense or not. Any help would be nice since I have been stuck on this for a while. Thank you for your help! </p> </div>

在中国程序员是青春饭吗?

今年,我也32了 ,为了不给大家误导,咨询了猎头、圈内好友,以及年过35岁的几位老程序员……舍了老脸去揭人家伤疤……希望能给大家以帮助,记得帮我点赞哦。 目录: 你以为的人生 一次又一次的伤害 猎头界的真相 如何应对互联网行业的「中年危机」 一、你以为的人生 刚入行时,拿着傲人的工资,想着好好干,以为我们的人生是这样的: 等真到了那一天,你会发现,你的人生很可能是这样的: ...

程序员请照顾好自己,周末病魔差点一套带走我。

程序员在一个周末的时间,得了重病,差点当场去世,还好及时挽救回来了。

和黑客斗争的 6 天!

互联网公司工作,很难避免不和黑客们打交道,我呆过的两家互联网公司,几乎每月每天每分钟都有黑客在公司网站上扫描。有的是寻找 Sql 注入的缺口,有的是寻找线上服务器可能存在的漏洞,大部分都...

搜狗输入法也在挑战国人的智商!

故事总是一个接着一个到来...上周写完《鲁大师已经彻底沦为一款垃圾流氓软件!》这篇文章之后,鲁大师的市场工作人员就找到了我,希望把这篇文章删除掉。经过一番沟通我先把这篇文章从公号中删除了...

总结了 150 余个神奇网站,你不来瞅瞅吗?

原博客再更新,可能就没了,之后将持续更新本篇博客。

副业收入是我做程序媛的3倍,工作外的B面人生是怎样的?

提到“程序员”,多数人脑海里首先想到的大约是:为人木讷、薪水超高、工作枯燥…… 然而,当离开工作岗位,撕去层层标签,脱下“程序员”这身外套,有的人生动又有趣,马上展现出了完全不同的A/B面人生! 不论是简单的爱好,还是正经的副业,他们都干得同样出色。偶尔,还能和程序员的特质结合,产生奇妙的“化学反应”。 @Charlotte:平日素颜示人,周末美妆博主 大家都以为程序媛也个个不修边幅,但我们也许...

MySQL数据库面试题(2020最新版)

文章目录数据库基础知识为什么要使用数据库什么是SQL?什么是MySQL?数据库三大范式是什么mysql有关权限的表都有哪几个MySQL的binlog有有几种录入格式?分别有什么区别?数据类型mysql有哪些数据类型引擎MySQL存储引擎MyISAM与InnoDB区别MyISAM索引与InnoDB索引的区别?InnoDB引擎的4大特性存储引擎选择索引什么是索引?索引有哪些优缺点?索引使用场景(重点)...

如果你是老板,你会不会踢了这样的员工?

有个好朋友ZS,是技术总监,昨天问我:“有一个老下属,跟了我很多年,做事勤勤恳恳,主动性也很好。但随着公司的发展,他的进步速度,跟不上团队的步伐了,有点...

我入职阿里后,才知道原来简历这么写

私下里,有不少读者问我:“二哥,如何才能写出一份专业的技术简历呢?我总感觉自己写的简历太烂了,所以投了无数份,都石沉大海了。”说实话,我自己好多年没有写过简历了,但我认识的一个同行,他在阿里,给我说了一些他当年写简历的方法论,我感觉太牛逼了,实在是忍不住,就分享了出来,希望能够帮助到你。 01、简历的本质 作为简历的撰写者,你必须要搞清楚一点,简历的本质是什么,它就是为了来销售你的价值主张的。往深...

优雅的替换if-else语句

场景 日常开发,if-else语句写的不少吧??当逻辑分支非常多的时候,if-else套了一层又一层,虽然业务功能倒是实现了,但是看起来是真的很不优雅,尤其是对于我这种有强迫症的程序"猿",看到这么多if-else,脑袋瓜子就嗡嗡的,总想着解锁新姿势:干掉过多的if-else!!!本文将介绍三板斧手段: 优先判断条件,条件不满足的,逻辑及时中断返回; 采用策略模式+工厂模式; 结合注解,锦...

离职半年了,老东家又发 offer,回不回?

有小伙伴问松哥这个问题,他在上海某公司,在离职了几个月后,前公司的领导联系到他,希望他能够返聘回去,他很纠结要不要回去? 俗话说好马不吃回头草,但是这个小伙伴既然感到纠结了,我觉得至少说明了两个问题:1.曾经的公司还不错;2.现在的日子也不是很如意。否则应该就不会纠结了。 老实说,松哥之前也有过类似的经历,今天就来和小伙伴们聊聊回头草到底吃不吃。 首先一个基本观点,就是离职了也没必要和老东家弄的苦...

2020阿里全球数学大赛:3万名高手、4道题、2天2夜未交卷

阿里巴巴全球数学竞赛( Alibaba Global Mathematics Competition)由马云发起,由中国科学技术协会、阿里巴巴基金会、阿里巴巴达摩院共同举办。大赛不设报名门槛,全世界爱好数学的人都可参与,不论是否出身数学专业、是否投身数学研究。 2020年阿里巴巴达摩院邀请北京大学、剑桥大学、浙江大学等高校的顶尖数学教师组建了出题组。中科院院士、美国艺术与科学院院士、北京国际数学...

男生更看重女生的身材脸蛋,还是思想?

往往,我们看不进去大段大段的逻辑。深刻的哲理,往往短而精悍,一阵见血。问:产品经理挺漂亮的,有点心动,但不知道合不合得来。男生更看重女生的身材脸蛋,还是...

程序员为什么千万不要瞎努力?

本文作者用对比非常鲜明的两个开发团队的故事,讲解了敏捷开发之道 —— 如果你的团队缺乏统一标准的环境,那么即使勤劳努力,不仅会极其耗时而且成果甚微,使用...

为什么程序员做外包会被瞧不起?

二哥,有个事想询问下您的意见,您觉得应届生值得去外包吗?公司虽然挺大的,中xx,但待遇感觉挺低,马上要报到,挺纠结的。

当HR压你价,说你只值7K,你该怎么回答?

当HR压你价,说你只值7K时,你可以流畅地回答,记住,是流畅,不能犹豫。 礼貌地说:“7K是吗?了解了。嗯~其实我对贵司的面试官印象很好。只不过,现在我的手头上已经有一份11K的offer。来面试,主要也是自己对贵司挺有兴趣的,所以过来看看……”(未完) 这段话主要是陪HR互诈的同时,从公司兴趣,公司职员印象上,都给予对方正面的肯定,既能提升HR的好感度,又能让谈判气氛融洽,为后面的发挥留足空间。...

面试:第十六章:Java中级开发(16k)

HashMap底层实现原理,红黑树,B+树,B树的结构原理 Spring的AOP和IOC是什么?它们常见的使用场景有哪些?Spring事务,事务的属性,传播行为,数据库隔离级别 Spring和SpringMVC,MyBatis以及SpringBoot的注解分别有哪些?SpringMVC的工作原理,SpringBoot框架的优点,MyBatis框架的优点 SpringCould组件有哪些,他们...

面试阿里p7,被按在地上摩擦,鬼知道我经历了什么?

面试阿里p7被问到的问题(当时我只知道第一个):@Conditional是做什么的?@Conditional多个条件是什么逻辑关系?条件判断在什么时候执...

面试了一个 31 岁程序员,让我有所触动,30岁以上的程序员该何去何从?

最近面试了一个31岁8年经验的程序猿,让我有点感慨,大龄程序猿该何去何从。

大三实习生,字节跳动面经分享,已拿Offer

说实话,自己的算法,我一个不会,太难了吧

程序员垃圾简历长什么样?

已经连续五年参加大厂校招、社招的技术面试工作,简历看的不下于万份 这篇文章会用实例告诉你,什么是差的程序员简历! 疫情快要结束了,各个公司也都开始春招了,作为即将红遍大江南北的新晋UP主,那当然要为小伙伴们做点事(手动狗头)。 就在公众号里公开征简历,义务帮大家看,并一一点评。《启舰:春招在即,义务帮大家看看简历吧》 一石激起千层浪,三天收到两百多封简历。 花光了两个星期的所有空闲时...

《Oracle Java SE编程自学与面试指南》最佳学习路线图2020年最新版(进大厂必备)

正确选择比瞎努力更重要!

《Oracle Java SE编程自学与面试指南》最佳学习路线图(2020最新版)

正确选择比瞎努力更重要!

都前后端分离了,咱就别做页面跳转了!统统 JSON 交互

文章目录1. 无状态登录1.1 什么是有状态1.2 什么是无状态1.3 如何实现无状态1.4 各自优缺点2. 登录交互2.1 前后端分离的数据交互2.2 登录成功2.3 登录失败3. 未认证处理方案4. 注销登录 这是本系列的第四篇,有小伙伴找不到之前文章,松哥给大家列一个索引出来: 挖一个大坑,Spring Security 开搞! 松哥手把手带你入门 Spring Security,别再问密...

字节跳动面试官竟然问了我JDBC?

轻松等回家通知

面试官:你连SSO都不懂,就别来面试了

大厂竟然要考我SSO,卧槽。

阿里面试官让我用Zk(Zookeeper)实现分布式锁

他可能没想到,我当场手写出来了

终于,月薪过5万了!

来看几个问题想不想月薪超过5万?想不想进入公司架构组?想不想成为项目组的负责人?想不想成为spring的高手,超越99%的对手?那么本文内容是你必须要掌握的。本文主要详解bean的生命...

自从喜欢上了B站这12个UP主,我越来越觉得自己是个废柴了!

不怕告诉你,我自从喜欢上了这12个UP主,哔哩哔哩成为了我手机上最耗电的软件,几乎每天都会看,可是吧,看的越多,我就越觉得自己是个废柴,唉,老天不公啊,不信你看看…… 间接性踌躇满志,持续性混吃等死,都是因为你们……但是,自己的学习力在慢慢变强,这是不容忽视的,推荐给你们! 都说B站是个宝,可是有人不会挖啊,没事,今天咱挖好的送你一箩筐,首先啊,我在B站上最喜欢看这个家伙的视频了,为啥 ,咱撇...

代码注释如此沙雕,会玩还是你们程序员!

某站后端代码被“开源”,同时刷遍全网的,还有代码里的那些神注释。 我们这才知道,原来程序员个个都是段子手;这么多年来,我们也走过了他们的无数套路… 首先,产品经理,是永远永远吐槽不完的!网友的评论也非常扎心,说看这些代码就像在阅读程序员的日记,每一页都写满了对产品经理的恨。 然后,也要发出直击灵魂的质问:你是尊贵的付费大会员吗? 这不禁让人想起之前某音乐app的穷逼Vip,果然,穷逼在哪里都是...

立即提问
相关内容推荐