我的表单底部有这样的代码。
public string menuEncrypt(string[] input, MainActivity ac)
{
//Stream Reader to String[]
StreamReader mc = new StreamReader(ac.Assets.Open("Menu_Code.txt"));
StreamReader mt = new StreamReader(ac.Assets.Open("Menu_Text.txt"));
string[] code = streamToArry(mc);
string[] text = streamToArry(mt);
//string[] code = File.ReadAllLines(@"JittersApp/Droid/Assets/Menu Code.txt");
//string[] text = File.ReadAllLines(@"JittersApp/Droid/Assets/Menu Text.txt");
int codemax = code.Length;
int current = 0;
int im = input.Length;
string menu = "oder ";
while (true)
{
if (current < codemax)
{
if (current < im)
{
if (text.Contains(input[current]))
{
int num = 0;
while (true)
{
string item = input[current];
if (text[num + 1].Equals(item))
{
menu = menu + code[num + 1] + " ";
break;
}
else
{
num++;
}
}
}
current++;
}
else
{
break;
}
}
else
{
break;
}
}
new AlertDialog.Builder(ac)
.SetMessage(menu)
.Show();
return menu;
}
我希望JavaScript中的侦听器能够启用提交按钮。 我知道它可能是错误的,但我的JavaScript看起来有点像这样
<p>
<input type="checkbox" id="agreed">
I agree to keep my Username and Password confidential and uphold
the integrity of this pharmacy
</p>
<input type="submit" id="submit" disabled class="formbutton button-primary" value="Go">
答案 0 :(得分:23)
您可以为输入执行此操作:
<input type='checkbox' onchange='handleChange(this);'>Checkbox
这是启用按钮:
function handleChange(checkbox) {
if(checkbox.checked == true){
document.getElementById("submit").removeAttribute("disabled");
}else{
document.getElementById("submit").setAttribute("disabled", "disabled");
}
}
答案 1 :(得分:2)
使用jQuery尝试下面的要求。
$('#checky').click(function(){
if($(this).attr('checked') == false){
$('#postme').attr("disabled","disabled");
}
else {
$('#postme').removeAttr('disabled');
}
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script>
<input type="checkbox" checked="checked" id="checky"><a href="#">I agree to keep my Username and Password confidential and uphold
the integrity of this pharmacy</a>
<br>
<input type="submit" id="postme" value="submit">
使用JavaScript,请参阅This