import multiprocessing as mp
import daemon
class MyProcess(mp.Process):
def __init__(self, target, args):
mp.Process.__init__(self, target=target, args=args)
while True:
running = get_runnig_instances() #get all the running gerrit instances
for instance in running:
port_num = instance.port
url = instance.ip
with daemon.DaemonContext():
proc = MyProcess(target=client_setup, args=(url,port_num,)) #client_setup(url,port_num) is a function that runs the command for the ssh connection to stream gerrit events
proc.start()
proc.join()

我想根据所选的下拉选项值在文本字段中生成自动前缀号码。 例如:如果我选择“退出访谈”,则自动生成的前缀将是“EI12345”,此处为“EI'来自下拉值和' 12345'是一个自动序列号。
答案 0 :(得分:1)
您可以使用Math.random()
生成任意位数的随机数。试试这个:
$("#questionnaire_domain").change(function() {
var val = $(this).val();
var random = Math.floor(Math.random()*90000) + 10000; // this will generate random number
$("#questionnaire_code").val(val+""+random);
});
答案 1 :(得分:1)
在input
onchange
select
之后nextElementSibling
更新<html>
<head>
<script src="//cdn.bootcss.com/jquery/2.2.1/jquery.js"></script>
</head>
<body>
up vote 0 down vote favorite
<select id="questionnaire_domain" class="form-control sync-option-text required" name="questionnaire_domain" onchange="this.nextElementSibling.value = this.value + this.nextElementSibling.value.match(/(\d+)/)[1];">
<option value="ESS">Employee Satisfaction Survey</option>
<option value="CSS">Customer Satisfaction Survey</option>
<option value="VSS">Vendor Satisfaction Survey</option>
<option value="OQ">Orientation Quiz</option>
<option value="TQ">Training Quiz</option>
<option value="EI">Exit Interview</option>
<option value="EO">Employee Opinion</option>
</select>
<input class="form-control readonly" name="questionnaire_code" type="text" value="11" id="questionnaire_code" readonly="">
</body>
值:
public String toString()
答案 2 :(得分:1)
我认为序列号的生成是基于下拉列表的selectedindexchange?如果是这样,请考虑以下代码段
$(document).ready(function(){
var sequence_no = 1;
$('#questionnaire_domain').change(function() {
$("#questionnaire_code").val($(this).id + sequence_no);
sequence_no += 1;
});
});
答案 3 :(得分:0)
jx create cluster