textbox does not active by clicking on radio button

青春壹個敷衍的年華 提交于 2019-12-23 07:02:58

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!