问题
i have created two radio button to get value i.ee max it goes to same varibale total. i wanted to active only one textbox at a time. and accept value.
<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;
}
回答1:
there were some syntax error.
Check below working code-
<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>
Updated JSFiddle- https://jsfiddle.net/vikash2402/f2hxt25d/6/
Hoping this will help you :)
来源:https://stackoverflow.com/questions/43800335/textbox-does-not-active-by-clicking-on-radio-button