我创建了两个单选按钮来获取值,即最大值达到相同的varibale总值。我想一次只激活一个文本框。并接受价值。
<dt>
<dd>
<input id="clicking" data-dojo-type="dijit/form/RadioButton" name="method" type="radio" value="clickarea" checked="false">
<label for="clicking">By Clicking</label><br>
<input type="text" name="Name" data-dojo-type="dijit/form/TextBox"
data-dojo-props="trim:true, propercase:true" value="" id="Area1" disabled = "true" >
</dd>
</dt>
<br></br>
<dt>
<dd>
<input id="draw" data-dojo-type="dijit/form/RadioButton" name="method" type="radio" value="drawarea" >
<label for="draw">Draw Area</label><br>
<input type="text" name="Name" data-dojo-type="dijit/form/TextBox"
data-dojo-props="trim:true, propercase:true" value="" id="Area2" disabled = "true"">
</dd>
</dt>
if (document.getElementById('clicking').checked) {
document.getElementById('Area1').disabled = false;
var container = dijit.byId("Area1");
container.set("value", evt.graphic.attributes.Area_);
area = container;
} else {
document.getElementById('Area1').disabled = true;
}
if (document.getElementById('draw').checked) {
document.getElementById('Area2').disabled = false;
area = e.values;
document.getElementById("Area2").value = area.toFixed(2);
} else {
document.getElementById('Area2').disabled = true;
}
答案 0 :(得分:1)
有一些语法错误。
检查以下工作代码 -
<link rel="stylesheet" href="https://js.arcgis.com/3.20/dijit/themes/claro/claro.css">
<link rel="stylesheet" href="https://js.arcgis.com/3.20/esri/css/esri.css">
<script src="https://js.arcgis.com/3.20/">
</script>
<script>
function enableDisableTextArea(){
if (document.getElementById('clicking').checked) {
document.getElementById('Area1').disabled = false;
var container = dijit.byId("Area1");
//container.set("value", evt.graphic.attributes.Area_); // get this value first
area = container;
} else {
document.getElementById('Area1').disabled = true;
}
if (document.getElementById('draw').checked) {
document.getElementById('Area2').disabled = false;
// area = e.values; //need to get this value first
//document.getElementById("Area2").value = area.toFixed(2);
} else {
document.getElementById('Area2').disabled = true;
}
}
</script>
<dt>
<dd>
<input id="clicking" data-dojo-type="dijit/form/RadioButton" name="method" type="radio" value="clickarea" checked="false" onClick ="enableDisableTextArea()">
<label for="clicking">By Clicking</label><br>
<input type="text" name="Name" data-dojo-type="dijit/form/TextBox"
data-dojo-props="trim:true, propercase:true" value="" id="Area1" >
</dd>
</dt>
<br></br>
<dt>
<dd>
<input id="draw" data-dojo-type="dijit/form/RadioButton" name="method" type="radio" value="drawarea" onClick ="enableDisableTextArea()">
<label for="draw">Draw Area</label><br>
<input type="text" name="Name" data-dojo-type="dijit/form/TextBox"
data-dojo-props="trim:true, propercase:true" value="" id="Area2" disabled = "true"">
</dd>
</dt>
&#13;
更新了JSFiddle - https://jsfiddle.net/vikash2402/f2hxt25d/6/
希望这会对你有所帮助:)。