html - ASP Radio button will not select when calling JavaScript function onClick -


my javascript working perfectly, though radio buttons not display checked when clicked. when alt+tab away web page , alt+tab back, shows shaded circle around radio button, still no proper check fill. why this?

i'm hoping easy fix. updated asp radio button call javascript function asp codebehind issuing postback , clearing controls on page. needless say, asp c# code behind functionality, radio buttons checking when clicked. need see checks on radio buttons when clicked javascript functionality in place. here radio control html:

<div class="col s12 form-section" id="crimeinsurance">             <h4 class="section-heading">crime insurance</h4>             <p>                 <asp:radiobutton id="radllcrimeins" runat="server" groupname="crimeinsurance" clientidmode="static" cssclass="with-gap" onclick="return crimeinsurancetoggle();" autopostback="true" text="accept crime insurance (fee of $250.00)" />             </p>             <p>                 <asp:radiobutton id="radllnocrimeins" runat="server" groupname="crimeinsurance" clientidmode="static" cssclass="with-gap" onclick="return crimeinsurancetoggle();" autopostback="true" text="do not accept crime insurance" />             </p>         </div> 

and here javascript method:

function crimeinsurancetoggle() {         //controls crime insurance radio yes/no buttons update crime insurance fees         var ocrimerte = document.getelementbyid("lblcrimecovflatrate");         var ocrimettl = document.getelementbyid("lblcrimecovamtdue");         var ocrimey = document.getelementbyid("radllcrimeins");         var ocrimen = document.getelementbyid("radllnocrimeins");          var radios = document.getelementsbytagname('input');         var value;         (var = 0; < radios.length; i++) {             if (radios[i].type === 'radio' && radios[i].checked) {                 //find each radio checked, , act on id                 value = radios[i].value;                 if (value == 'radllcrimeins') {                     ocrimettl.innerhtml = ocrimerte.innerhtml;                     radios[i].checked = true;                 }                 else if (value == 'radllnocrimeins') {                     ocrimettl.innerhtml = "0.00";                     radios[i].checked = true;                 }             }         }          return false;     } 

help appreciated.

your function returns false prevents radio button ever being checked.

try (not tested):

markup (notice pass in element reference function):

<div class="col s12 form-section" id="crimeinsurance">   <h4 class="section-heading">crime insurance</h4>   <p>     <asp:radiobutton id="radllcrimeins" runat="server" groupname="crimeinsurance" clientidmode="static" cssclass="with-gap" onclick="return crimeinsurancetoggle(this);" autopostback="true" text="accept crime insurance (fee of $250.00)" />   </p>   <p>     <asp:radiobutton id="radllnocrimeins" runat="server" groupname="crimeinsurance" clientidmode="static" cssclass="with-gap" onclick="return crimeinsurancetoggle(this);" autopostback="true" text="do not accept crime insurance" />   </p> </div> 

javascript:

function crimeinsurancetoggle(rdo) {   //controls crime insurance radio yes/no buttons update crime insurance fees   var ocrimerte = document.getelementbyid("lblcrimecovflatrate");   var ocrimettl = document.getelementbyid("lblcrimecovamtdue");    //find each radio checked, , act on id   if (rdo.id == 'radllcrimeins') {     ocrimettl.innerhtml = ocrimerte.innerhtml;   } else if (rdo.id == 'radllnocrimeins') {     ocrimettl.innerhtml = "0.00";   }    return rdo.checked; } 

Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -