永发信息网

JS 的问题!! 请求帮助 ..急..

答案:1  悬赏:50  手机版
解决时间 2021-05-01 15:33
  • 提问者网友:暗中人
  • 2021-04-30 21:01

我有2条JS的问题!! 请求帮助

 

第一条简单的问题 : 请将以下的JS码,"默认下拉"的部份删除
请看图了解 : http://pic.qnpic.com:83/r.jsp?fn=//qiannao/share/2010/8/3/dgr.jpg

 

<SCRIPT LANGUAGE="JavaScript">
function getrandom(){var seed = '0123456789', i = 0, len = seed.length, max = 8, rs = '', min = 0;var def = new Array(8397, 56, 379);var st = document.getElementById('sel').value || 0;if (st == 0)rs = def[Math.floor(Math.random() * def.length)].toString(); else rs = st.toString();min = rs.length;for (i = 0; i < max - min; i++)rs += seed.substr(Math.floor(Math.random() * len), 1);document.getElementById('getrandoms').value = rs;}

window.onload = function(){getrandom();}
</SCRIPT>
<input type="text" id="getrandoms" /> <select id="sel"><option value="0">默认</option></select> <input type="button" value=" GO " onclick="javascript:getrandom();" />

 

第二条深入问题 : 想将以下的JS代码,修改為以"开头"的数字决定显示 7 位数字或8位数字

例如 : 开头的数字有"8397﹑56﹑79",将开头的数字8397分组為显示7位数字,将56﹑79开头的数字显示為8位字

 

如果选择了7位数字
8397xxxx

 

如果选择了8位数字
56xxxxxx
79xxxxxx

 

如果没有选择随机显示开头的7位数字或8位字数字

 

请看图了解 : http://pic.qnpic.com:83/r.jsp?fn=//qiannao/share/2010/8/3/ert.jpg

 

<SCRIPT LANGUAGE="JavaScript">
function getrandom(){var seed = '0123456789', i = 0, len = seed.length, max = 8, rs = '', min = 0;var def = new Array(8397, 56, 379);var st = document.getElementById('sel').value || 0;if (st == 0)rs = def[Math.floor(Math.random() * def.length)].toString(); else rs = st.toString();min = rs.length;for (i = 0; i < max - min; i++)rs += seed.substr(Math.floor(Math.random() * len), 1);document.getElementById('getrandoms').value = rs;}

window.onload = function(){getrandom();}
</SCRIPT>
<input type="text" id="getrandoms" /> <select id="sel"><option value="0">默认随机显示7位或8位数字</option><option value="56,379">8位数字</option><option value="8397">7位数字</option><></select> <input type="button" value=" GO " onclick="javascript:getrandom();" />

最佳答案
  • 五星知识达人网友:话散在刀尖上
  • 2021-04-30 21:13

第一题:



<input type="text" id="getrandoms" /> <select id="sel"><option value="0">默认</option></select> <input type="button" value=" GO " onclick="javascript:getrandom();" />


中只要删除“<select id="sel"><option value="0">默认</option></select>”代码即可


即改为


<input type="text" id="getrandoms" /> <input type="button" value=" GO " onclick="javascript:getrandom();" />

我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯