我想填写一个下拉列表,我写了以下代码:
<script language="JavaScript1.2">
window.onload = fillDropDown();
function fillDropDown() {
var ddl = document.getElementById("dia");
var theOption = new Option;
var x;
var i;
for(i = 1; i < 32; i++) {
x = i + 1;
theOption.text = x;
theOption.value = x;
ddl.options[i] = theOption;
}
}
</script>
<body>
<form>
<select id=dia></select>
</form>
<body>
Run Code Online (Sandbox Code Playgroud)
它不起作用,任何想法为什么?
我有这个元组列表:
t_s = [((1, 0, 0), 1), ((1, 0, 1), 1), ((1, 1, 0), 1), ((1, 1, 1), 0)]
Run Code Online (Sandbox Code Playgroud)
我想变成:
clean_t_s = [((0, 0), 1), ((0, 1), 1), ((1, 0), 1), ((1, 1), 0)]
Run Code Online (Sandbox Code Playgroud)
我怎么能这么做呢?
我正在使用Konrad Rudolph提出的算法实现本文和另一篇文章中描述的非确定性有限自动机.
我没有使用C++多图,而是使用了一个HashSet<Character> [][] transitions数组(这是家庭作业,Google的番石榴库不能使用).第一维是原始状态,第二维是命运状态,而HashSet定义原点和命运状态之间转换的符号.我的Automaton类的构造函数是:
Automaton (int numberOfStates)
{
this.numberOfStates = numberOfStates;
alphabet = new HashSet<>();
finalStates = new HashSet<>();
transitions = new HashSet[numberOfStates][numberOfStates];
for (int i = 0; i < numberOfStates; i++)
{
for (int j = 0; j < numberOfStates; j++)
{
transitions[i][j] = new HashSet<Character>();
}
}
}
Run Code Online (Sandbox Code Playgroud)
这是我使用此过渡数组实现的Konrad Rudolph算法:
public String readStringInAutomaton (char[] inputString,
int initialState)
{
HashSet<Integer> currentStates = new HashSet<>();
HashSet<Integer> nextStates = new HashSet<>();
currentStates.add(initialState);
// …Run Code Online (Sandbox Code Playgroud) 我有一个HTML表单.
我希望用户能够标记三个复选框.如果他标记超过三个,我想立即发送警告信息.我该怎么做呢?(以前从未使用过JavaScript).