JavaScript随机生成信用卡卡号的办法_javascript技能_脚本之家

本文实例讲述了JavaScript生成SQL查询表单的方法。分享给大家供大家参考。具体如下:

本文实例讲述了JavaScript生成随机字符串的方法。分享给大家供大家参考。具体分析如下:

废话不多说了直接给大家贴js代码了,具体代码如下所述:

本文实例讲述了JavaScript随机生成信用卡卡号的方法。分享给大家供大家参考。具体分析如下:

复制代码 代码如下:function User{ for{
//遍历该对象的所有属性,并保证其作用于正确 { var p=i;
which[“get”+p]=function(){ //动态生成的方法 return properties[p];
//返回对象的属性值 }; which[“set”+p]=function{ //动态生成的方法
properties[p]=val; }; }); //自执行函数,this在这里表示用户对象实例 } }
var user=new User({ name:”Bob”, age:44 }); alert;
//注意:name属性并不存在,因为它是属性对象的私有变量 user.setname;
//调用动态生成的对象,修改属性对象的值 alert;
//调用动态生成的对象,获取属性对象的值

这里使用JavaScript生成复杂的SQL查询表单,运行一下就明白了,它可以根据选择的查询条件,自动修改你的SQL语句,是一个很典型的应用。

这里使用JavaScript生成一个随机字符串,可以指定字符串的长度。复制代码 代码如下:function RandomString { var
str = ”; for ( ; str.length < length; str += Math.random.substr;
return str.substr;}

调用第一种调用第二种调用第三种var btn1=document.getElementById;btn1.onclick=function(){document.body.style.background=bg1()};var btn2=document.getElementById;btn2.onclick=function(){document.body.style.background=bg2();};var btn3=document.getElementById;btn3.onclick=function(){document.body.style.background=bg3{return '#'+Math.floor.toString{return '#'+Math.floor*0xffffff).toString{var r=Math.floor;var g=Math.floor;var b=Math.floor;return "rgb";//&#25152;&#26377;&#26041;&#27861;&#30340;&#25340;&#25509;&#37117;&#21487;&#20197;&#29992;ES6&#26032;&#29305;&#24615;`&#20854;&#20182;&#23383;&#31526;&#20018;{$&#21464;&#37327;&#21517;}`&#26367;&#25442;}

这段JS代码根据信用卡卡号产生规则随机生成信用卡卡号,是可以通过验证的,仅供学习参考,请不要用于非法用途,否则后果自负。

查询条件表单*{ font-size:12px; padding:0; margin:0;}body{ padding:40px;}#MainBox{ border:#666 1px solid; background-color:#eee; width:700px;}#MainBox td{ padding:4px;}#ConditionBox{ height:150px; width:100%; overflow-y:auto; border:#bbb 1px solid; padding:2px; background-color:#fff;}.tmFrame{ border:#eee 1px solid; padding:2px; width:100%;}.tmFrame_highlight{ border:#666 1px solid; padding:2px; width:100%; background-color:#f7f7f7;}.fname{ float:left; width:200px;}.conn{ float:left; width:100px;}.fvalue{ float:left; width:100px;}.handlebox{ float:right; width:180px; display:none;}.handlebox_view{ float:right; width:180px; display:block;}.rbox{ float:right; margin:1px; background-color:#999; color:#fff; padding:1px; width:15px; cursor:hand;}legend{ border:#bbb 1px solid; padding:4px;}fieldset{ border:#bbb 1px solid; padding:4px;}.sqlwords{ margin:2px; border:#bbb 1px solid; width:100%;}////&#26500;&#36896;&#20989;&#25968;function ce{return document.createElement}/* Example:* var a = cex("DIV", {onmouseover:foo, name:'div1', id:'main'});*/function cex; for { a[prop] = x[prop]; } return a;}/** function ge* Shorthand function for document.getElementById{return document.getElementById}/** function ac* Example: ac( house, ac, ac(floor, ac*/function ac(){ if (ac.arguments.length &gt; 1){ var a = ac.arguments[0]; for (i=1; i&lt;ac.arguments.length; i++){ if  a.appendChild; } return a; } else { return null; }}/////ID&#22686;&#37327;function guid window.__id = 0; return ++window.__id;}//======&#24314;&#31435;&#26465;&#20214;&#31867;function term(tname,fname,conn,fvalue,ttype){ this.tname=tname; this.fname=fname; this.conn=conn; this.fvalue=fvalue; this.id= guid(); this.ttype=ttype;}term.prototype.getHTML = function(){ var termFrame = cex("DIV", { id:this.id, className:'tmframe', onmouseover:this.fc_term_onmouseover(), onmouseout:this.fc_term_onmouseout; //var module = cex("DIV", { //id:'module'+this.id, //className:'module' //}); var tttt=this.tname+"."+this.fname; if tttt=this.tname; var mtt = cex("input", { id:'tp'+this.id, name:'fname'+this.id, type:"hidden", value:this.ttype }); var fname = cex("DIV", { id:'fname'+this.id, className:'fname', innerHTML:tttt }); var conn = cex("DIV", { id:'conn'+this.id, className:'conn', innerHTML:this.conn }); var fvalue = cex("DIV", { id:'fvalue'+this.id, className:'fvalue', innerHTML:this.fvalue }); var handlebox = cex("div", { id:'handlebox'+this.id, className:"handlebox" }); var mdel = cex("div", { id:'tmdel'+this.id, onclick:this.fc_mdel_onclick(), className:"rbox", title:"&#21024;&#38500;&#27492;&#26465;&#20214;", innerHTML: 'X' }); var mup = cex("div", { id:'tmup'+this.id, onclick:this.fc_mup_onclick(), className:"rbox", title:"&#21521;&#19978;&#31227;&#21160;", innerHTML: '&#8593;' }); var mdown = cex("div", { id:'tmdown'+this.id, onclick:this.fc_mdown_onclick(), className:"rbox", title:"&#21521;&#19979;&#31227;&#21160;", innerHTML: '&#8595;' }); var mzkh = cex("div", { id:'tzkh'+this.id, onclick:this.fc_mzkh_onclick(), className:"rbox", title:"&#28155;&#21152;&#24038;&#25324;&#21495;", innerHTML: '; var mykh = cex("div", { id:'tykh'+this.id, onclick:this.fc_mykh_onclick(), className:"rbox", title:"&#28155;&#21152;&#21491;&#25324;&#21495;", innerHTML: ')' }); var mand = cex("div", { id:'tand'+this.id, onclick:this.fc_mand_onclick(), className:"rbox", title:"&#28155;&#21152;&#24182;&#26465;&#20214;", innerHTML: 'and' }); var mor = cex("div", { id:'tor'+this.id, onclick:this.fc_mor_onclick(), className:"rbox", title:"&#28155;&#21152;&#25110;&#26465;&#20214;", innerHTML: 'or' }); // Build DIV ac (termFrame, mtt, ac (handlebox, mdel, mup, mdown, mykh, mzkh, mand, mor ), fname, conn, fvalue ); return termFrame;}term.prototype.highlight = function(){ ge.className = 'handlebox_view'; ge.className = 'tmFrame_highlight';}term.prototype.lowlight = function(){ ge.className = 'handlebox'; ge.className = 'tmFrame';}term.prototype.remove = function(){ var _this = ge; _this.parentNode.removeChild;}term.prototype.moveup = function(){ var _this = ge; var pre_this = _this.previousSibling; if{ _this.parentNode.insertBefore; this.lowlight(); }}term.prototype.movedown = function(){ var _this = ge; var next_this = _this.nextSibling; if{ _this.parentNode.insertBefore; this.lowlight(); }}term.prototype.addzkh = function(){ var _this = ge; var tzkh = new term('&#9581;----------------','','','','zkh'); var node_zkh = tzkh.getHTML(); _this.parentNode.insertBefore;}term.prototype.addykh = function(){ var _this = ge; var tykh = new term('&#9584;----------------','','','','ykh'); var node_ykh = tykh.getHTML(); if(_this.nextSibling!=null) _this.parentNode.insertBefore(node_ykh,_this.nextSibling); else _this.parentNode.appendChild;}term.prototype.addand = function(){ var _this = ge; var tand = new term(' &#24182;&#19988;','','','','tand'); var node_and = tand.getHTML(); if(_this.nextSibling!=null) _this.parentNode.insertBefore(node_and,_this.nextSibling); else _this.parentNode.appendChild;}term.prototype.addor = function(){ var _this = ge; var tor = new term; var node_or = tor.getHTML(); if(_this.nextSibling!=null) _this.parentNode.insertBefore(node_or,_this.nextSibling); else _this.parentNode.appendChild;}///&#23545;&#35937;&#25511;&#21046;&#20989;&#25968;term.prototype.fc_term_onmouseover = function(){ var _this = this; return function(){ //if  _this.highlight(); }}term.prototype.fc_term_onmouseout = function(){ var _this = this; return function(){ //if  _this.lowlight(); }}term.prototype.fc_mdel_onclick = function(){ var _this = this; return function; }}term.prototype.fc_mup_onclick = function(){ var _this = this; return function; }}term.prototype.fc_mdown_onclick = function(){ var _this = this; return function; }}term.prototype.fc_mzkh_onclick = function(){ var _this = this; return function; }}term.prototype.fc_mykh_onclick = function(){ var _this = this; return function; }}term.prototype.fc_mand_onclick = function(){ var _this = this; return function; }}term.prototype.fc_mor_onclick = function(){ var _this = this; return function; }}/////&#25554;&#20837;&#39029;&#38754;function insertterm(){ var tname = document.all.tname.value; var fname = document.all.fname.value; var conn = document.all.conn.value; var fvalue = document.all.fvalue.value; //xl(tname+"|"+fname+"|"+conn+"|"+fvalue); var tm = new term(tname,fname,conn,fvalue,"fset"); var tmHTML = tm.getHTML(); ac,tmHTML); //ZA.addterm;}var tt = new Array();function addtofrom{ var ttexit="no"; for(var i=0;i&lt;tt.length;i++){ if ttexit="yes"; } if{ tt[i]=tname; //alert; }}//====&#26465;&#20214;&#25511;&#21046;&#31383;&#21475;&#20989;&#25968;function CBadd(){ var h = document.all.ConditionBox.offsetHeight; document.all.ConditionBox.style.height = h + 20 + "px";}function CBcut(){ var h = document.all.ConditionBox.offsetHeight; if document.all.ConditionBox.style.height = h - 20 + "px"; else return false;}function getSQL(){ var sql=""; var ma = ge.childNodes; for{ var id = ma[i].getAttribute; var tp = ge.value; if{ //sql+=" "+ge.innerHTML; //sql+=" "+ge.innerHTML; //sql+=" \""+ge.innerHTML+"\""; var fname=ge.innerHTML; var conn=ge.innerHTML; var fvalue=ge.innerHTML; sql+=" "+fname; if sql+=" = "+"\'"+fvalue+"\'"; if sql+=" &gt; "+"\'"+fvalue+"\'"; if sql+=" &lt; "+"\'"+fvalue+"\'"; if sql+=" &lt;&gt; "+"\'"+fvalue+"\'"; if sql+=" is null "; if sql+=" is not null "; if sql+=" like \'%"+fvalue+"%\'"; } else{ //sql+=" "+ge.innerHTML; if sql+="  sql+=" )"; if sql+=" and"; if sql+=" or"; } //var mn = ma.childNodes; } var ffrom = "FROM "+getFrom.value ="Select * "+ ffrom+" Where "+sql;}function getFrom(){ var ff=tt.toString(); return ff;}

希望本文所述对大家的javascript程序设计有所帮助。

以上所述是小编给大家介绍的JavaScript随机生成颜色的方法,希望对大家有所帮助,如果大家有任何疑问欢迎给我留言,小编会及时回复大家的,在此也非常感谢大家对脚本之家网站的支持!

var visaPrefixList = new Array( "4539", "4556", "4916", "4532", "4929", "40240071", "4485", "4716", "4");var mastercardPrefixList = new Array( "51", "52", "53", "54", "55");var amexPrefixList = new Array;var discoverPrefixList = new Array;var dinersPrefixList = new Array( "300", "301", "302", "303", "36", "38");var enRoutePrefixList = new Array;var jcbPrefixList = new Array;var voyagerPrefixList = new Array;function strrev return ''; var revstr=''; for (i = str.length-1; i>=0; i--) revstr+=str.charAt return revstr;}/*'prefix' is the start of the CC number as a string, any number of digits.'length' is the length of the CC number to generate. Typically 13 or 16*/function completed_number { var ccnumber = prefix; // generate digits while ( ccnumber.length <  { ccnumber += Math.floor; } // reverse number and convert to int var reversedCCnumberString = strrev; var reversedCCnumber = new Array(); for ( var i=0; i < reversedCCnumberString.length; i++ ) { reversedCCnumber[i] = parseInt(reversedCCnumberString.charAt; } // calculate sum var sum = 0; var pos = 0; while  { odd = reversedCCnumber[ pos ] * 2; if  { odd -= 9; } sum += odd; if  ) { sum += reversedCCnumber[ pos +1 ]; } pos += 2; } // calculate check digit var checkdigit = +1)*10-sum)%10; ccnumber += checkdigit; return ccnumber;}function credit_card_number(prefixList, length, howMany) { var result = new Array(); for (var i = 0; i < howMany; i++) { var randomArrayIndex = Math.floor * prefixList.length); var ccnumber = prefixList[ randomArrayIndex ]; result.push( completed_number; } return result;}

复杂查询表单

将上面的代码保存为gencc.js文件

65

VISA:var visa = credit_card_number(visaPrefixList, 16, 3);document.write;Amex:var amex = credit_card_number(amexPrefixList, 15, 3);document.write;

SQL表达式

希望本文所述对大家的javascript程序设计有所帮助。

定义条件

表1 表2 表3 表4 表5 字段 字段1 字段2 字段3 字段4 字段5 字段6 字段7 关系 大于 等于 小于 不等于 为空 不为空 包含

发表评论

电子邮件地址不会被公开。 必填项已用*标注