Home > front end >  JS perhaps the checkbox value is implemented, and according to the selected order
JS perhaps the checkbox value is implemented, and according to the selected order

Time:09-25

Four checkbox, in accordance with the order, after the elections in the array, not in order of each cycle,

CodePudding user response:

 


<meta charset="utf-8"/& gt;
<meta HTTP - equiv="X - UA - Compatible" content="IE=edge, chrome=1"/& gt;
The name of the page & lt;/title> <br/></head> <br/><body> <br/><Input type="checkbox" vhttps://bbs.csdn.net/topics/alue="a" onchange="sel (value). This"/& gt; <br/><Input type="checkbox" value="https://bbs.csdn.net/topics/b" onchange="sel (value). This"/& gt; <br/><Input type="checkbox" value="https://bbs.csdn.net/topics/c" onchange="sel (value). This"/& gt; <br/><Input type="checkbox" value="https://bbs.csdn.net/topics/d" onchange="sel (value). This"/& gt; <br/><Input type="text" id="text"/& gt; <br/><The script type="text/javascript" & gt; <br/>Var arr=[]; <br/>The function sel (v) {<br/>Var n=arr. IndexOf (v); <br/>If (n==1) {<br/>Arr. Push (v); <br/>} else {<br/>Arr. Splice (n, 1); <br/>} <br/>Document. The getElementById (" text ") value=https://bbs.csdn.net/topics/arr; <br/>} <br/></script> <br/></body> <br/></html> </pre><p class="article - content rp"> CodePudding user response: </p>Eldest brother, you provide this, very good, but a bit of a problem oh brother, I am wrong if two, <fieldset> <legend> reference <legend> <blockquote> <img SRC="https://img.codepudding.com/202009/103380250950051.png" Alt=""/> </blockquote> <fieldset><p class="article - content rp"> CodePudding user response: </p>Borrow 1/f, under the code change <br/><pre> & lt; ! Doctype html> <br/><HTML lang="en" & gt; <br/><head> <br/><meta charset="utf-8"/& gt; <br/><meta HTTP - equiv="X - UA - Compatible" content="IE=edge, chrome=1"/& gt; <br/><Title> The name of the page & lt;/title> <br/></head> <br/><body> <br/><Input type="checkbox" vhttps://bbs.csdn.net/topics/alue="a" onchange="sel (enclosing value, 'input1)"/& gt; <br/><Input type="checkbox" value="https://bbs.csdn.net/topics/b" onchange="sel (enclosing value, 'input1)"/& gt; <br/><Input type="checkbox" value="https://bbs.csdn.net/topics/c" onchange="sel (enclosing value, 'input1)"/& gt; <br/><Input type="checkbox" value="https://bbs.csdn.net/topics/d" onchange="sel (enclosing value, 'input1)"/& gt; <br/><Input type="text" id="input1"/& gt; <br/><Input type="checkbox" vhttps://bbs.csdn.net/topics/alue="a" onchange="sel (enclosing the value," input2 ") "/& gt; <br/><Input type="checkbox" value="https://bbs.csdn.net/topics/b" onchange="sel (enclosing the value," input2 ") "/& gt; <br/><Input type="checkbox" value="https://bbs.csdn.net/topics/c" onchange="sel (enclosing the value," input2 ") "/& gt; <br/><Input type="checkbox" value="https://bbs.csdn.net/topics/d" onchange="sel (enclosing the value," input2 ") "/& gt; <br/><Input type="text" id="input2"/& gt; <br/><The script type="text/javascript" & gt; <br/>Var arr={' input1: [], 'input2: []}. <br/>The function sel (v, name) {<br/>Var n=arr [name] indexOf (v); <br/>If (n==1) {<br/>Arr [name]. Push (v); <br/>} else {<br/>Arr [name]. Splice (n, 1); <br/>} <br/>Document. The getElementById (name). The value=https://bbs.csdn.net/topics/arr [name]; <br/>} <br/></script> <br/></body> <br/></html> </pre><p class="article - content rp"> CodePudding user response: </p>How to get sorting box? I want to make a judgment for sorting </div> <div class="th_page th_page_color"></div> <div class="umCopyright"> <p>Page link:<a href="/frontend/29632.html" target="_blank" style="color:#999">https//www.codepudding.com/frontend/29632.html</a></p> </div> <div class="detail-arr"> <div class="detail-arr-left">Prev:<a href='/frontend/29631.html'>Docking pay treasure box</a></div> <div class="detail-arr-right">Next:<a href='/frontend/29633.html'>Ordinary button to jump page</a></div> </div> </div> </div> </div> </div> <div class="container th_top"> <div class="row"> <div class="col-md-12"> <div class="hot-tags neitags"> <ul> <li><i class="iconfont icon-x-tags"></i> Tags:  </li> <a href='/e/tags/?tagname=JavaScript' target='_blank'>JavaScript</a> </ul> </div> </div> </div> </div> <div class="container th_top"> <div class="row"> <div class="col-md-12"> <div class="xiangguan"> <ul class="msg msghead"> <li class="tbname">Related</li> </ul> <ul> </ul> </div> </div> </div> </div> <div class="container th_top"> <div class="row"> <div class="col-md-12"> <div class="flinks"> <ul> <li><i class="iconfont icon-x-tags"></i> Links:  </li> <li class="liflinks"><a target="_blank" href="/" title="CodePudding">CodePudding</a></li> </ul> </div> </div> </div> </div> <div class="footer"> <p><span style="font-size:16px;color:#666;font-weight: bold">About Us:</span>  <a href="https://www.codepudding.com/contact.html">Contact Us</a>      <a href="https://www.codepudding.com/service.html">Terms of Service</a>      <a href="https://www.codepudding.com/privacy.html"> Privacy Policy</a></p> <p class="foot_info">Copyright © 2010-2023,Powered By <a href="/" target="_blank">CodePudding</a> </p> </div> <script type="text/javascript" src="/skin/code/tianhu.js"></script> </body></html>