尝试禁用“执行”按钮,直到单击“提交”按钮。 但单击“提交”按钮后,“执行”按钮应该启用。
HTML -
<form id="form1" name="form1" method="post" action="" >
<span id="spryselect1">
<label for="flow">Select Flow</label>
<select name="Select Flow" id="flow">
<option id="sendmoney" value="sendmoney">A</option>
<option id="sendmoneyp2p" value="sendmoneyp2p">Send Money P2P</option>
<option id="sendmoneyservice">Send Money Service</option>
<option id="econebay">Express Checkout - On eBay</option>
<option id="ecoffebay">Express Checkout - Off eBay</option>
<option id="gsp">Global Shipping Platform</option>
<option id="pos">TouchStone POS</option>
<option id="davisauthcapture">Davis Checkout - Auth & Capture</option>
<option id="davisfp">Davis Checkout - Forced Post</option>
</select>
<span id="sprytextfield1">
<label>Stage Name
<input type="text" name="stage" id="stage" />
Buyer
</label>
<span class="textfieldRequiredMsg"></span>
<label>
<select name="buyer" id="buyer">
<option>US</option>
<option>UK</option>
<option>CA</option>
<option>FR</option>
<option>DE</option>
<option>AU</option>
</select>
Seller
</label>
<span class="textfieldRequiredMsg"></span>
<label>
<select name="buyer2" id="buyer2">
<option>US</option>
<option>UK</option>
<option>CA</option>
<option>FR</option>
<option>DE</option>
<option>AU</option>
</select>
</label>
<label>
<input name="SubmitID" type="submit" id="SubmitID" />
<br />
<br />
Flow Description
<label for="Descrptn"></label>
<textarea name="Descrptn" id="Descrptn" cols="45" rows="1"></textarea>
<br />
<br />
<br />
Output
<textarea name="output" cols="45" rows="5" readonly="readonly" id="output">Output here</textarea>
<br />
<br />
<div align="center">
<input type="button" name="submitbutton" id="executebutton" value="Execute Flow" action="checkState()"/>
<input type="button" name="submitbutton" id="submitbutton2" value="Contribute"/>
</div>
<br />
</label>
<span class="textfieldRequiredMsg"></span></span>
</form>
JS -
document.getElementById("executebutton").disabled="true";
var button = document.getElementById("SubmitID");
function myfunc()
{
document.getElementById("executebutton").disabled="false";
}
答案 0 :(得分:0)
true
和false
是数据类型。不是字符串。
document.getElementById("executebutton").disabled=true;
var button = document.getElementById("SubmitID");
function myfunc()
{
document.getElementById("executebutton").disabled=false;
}
答案 1 :(得分:0)
disabled
属性不像布尔值那样工作;如果元素具有任何值的disabled
属性,则将禁用该属性。要重新启用该按钮,请删除已禁用的属性:
document.getElementById("executebutton").removeAttribute('disabled');
答案 2 :(得分:0)
document.getElementById("executebutton").disabled = true;
document.getElementById("SubmitID").onclick = function() {
document.getElementById("executebutton").disabled = false;
};
你去,测试自己。 (http://jsfiddle.net/VZ3jw/)