javascript - Why is this Undefined and how do i fix this? C# -


i'm creating scenario need 3 radio buttons multiple questions. added values radio button , want add total points of selected radio button , display text box.

here's code , i'm having difficulties trying figure out why i'm getting undefined error message. enter image description here

 function getselectionpoints(selection) {         return parseint(selection.split(",")[1]);     }      function getselectionobj(selectionid) {         var selection = null;          if(selectionid == 1)             selection = document.getelementbyid("<%=selection1.clientid %>").getelementsbytagname("input");         else if (selectionid == 2)             selection = document.getelementbyid("<%=selection2.clientid %>").getelementsbytagname("input");         else if (selectionid == 3)             selection = document.getelementbyid("<%=selection3.clientid %>").getelementsbytagname("input");          return selection;     }      function gettotalpoints() {         var totalpoints = 0;         var selection;         var promotiondropdown = document.getelementbyid("<%=dropdownpromotionto.clientid %>");         var promotionfromid = parseint(document.getelementbyid("<%=promotionidfromhidden.clientid %>").value);         var promotiontoid = parseint(promotiondropdown.options[promotiondropdown.selectedindex].value);          (var = 1; <= 9; i++) {             selection = getselectionobj(i);              if (i == 9 && (promotionfromid == 2 || promotionfromid == 3 || promotiontoid == 2 || promotiontoid == 3)) {                 totalpoints += 0;             }              else if (selection != null) {                 (var j = 0; j < selection.length; j++) {                     if (selection[j].checked) {                         totalpoints += getselectionpoints(selection[j].value);                         break;                     }                 }             }         }         alert(totalpoints);          return totalpoints;     }     <asp:radiobuttonlist id="selection1" runat="server"                     enabletheming="true" skinid="black" causesvalidation="true" onchange="updatemypoints(false, true);">                         <asp:listitem value="1,6">spectacular</asp:listitem>                         <asp:listitem value="2,4" selected="true">average</asp:listitem>                         <asp:listitem value="3,0">needs improvement</asp:listitem>                     </asp:radiobuttonlist> 

javascript case sensitive, use totalpoints instead of totalpoints:

alert(totalpoints);  

Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -