GetElementById Returns Undefined Value












0















I have a CheckboxList with 3 options.



In my javascript, I want to check which options are ticked.



But the validation did not go through as the var value retrieved is undefined.



javascript: EDIT



var schedule = document.getElementById("<%=ddlExecutionSchedule.ClientID%>").value; 
// ^ return as undefined

var schedule2 = document.getElementById("ddlExecutionSchedule").value;
// ^ return as undefined

var scheduleOptions = schedule.getElementsByTagName('input');
// ^ error: Uncaught TypeError: Cannot read property 'getElementsByTagName' of undefined


html:



<div class="form-group" id="divExecutionSchedule">
<label class="control-label col-md-2" id="lblExecutionSchedule">Execution Schedule</label>
<div class="col-md-3">
<div class="input-group">
<asp:CheckboxList ID="ddlExecutionSchedule" ClientIDMode="Static" CssClass="chkLabel" runat="server" AutoPostBack="false" CellPadding="5" CellSpacing="5" RepeatDirection="Horizontal" RepeatLayout="Table" onchange="ToggleExecutionSchedule(this)" >
<asp:ListItem Text="Daily" Value="Daily"></asp:ListItem>
<asp:ListItem Text="Weekly" Value="Weekly"></asp:ListItem>
<asp:ListItem Text="Monthly" Value="Monthly"></asp:ListItem>
</asp:CheckboxList>
</div>
</div>




c#:



//if (ddlExecutionSchedule.Text == "Weekly") // <= Commented off to allow catering for multiple checkboxes to be ticked at the same time
//{
string selectedDay = item["Days"] != null ? item["Days"].ToString() : string.Empty;

if (!string.IsNullOrEmpty(selectedDay))
{
List<string> day = selectedDay.Replace(";#",";").Split(';').ToList();
for (int i = 0; i < chkSelectDay.Items.Count; i++)
{
if (day.Contains(chkSelectDay.Items[i].Value))
{
//Check only if they match!
chkSelectDay.Items[i].Selected = true;
}
}
}
//}


I have went through the similar articles, and have tried several methods, including adding in GetElementsByTagName, but hit Uncaught TypeError.



Any help is greatly appreciated.










share|improve this question

























  • What you see document.getElementById("<%=ddlExecutionSchedule.ClientID%>").length in console

    – Mamun
    Nov 15 '18 at 5:49











  • @Mamun let me check

    – gymcode
    Nov 15 '18 at 5:50
















0















I have a CheckboxList with 3 options.



In my javascript, I want to check which options are ticked.



But the validation did not go through as the var value retrieved is undefined.



javascript: EDIT



var schedule = document.getElementById("<%=ddlExecutionSchedule.ClientID%>").value; 
// ^ return as undefined

var schedule2 = document.getElementById("ddlExecutionSchedule").value;
// ^ return as undefined

var scheduleOptions = schedule.getElementsByTagName('input');
// ^ error: Uncaught TypeError: Cannot read property 'getElementsByTagName' of undefined


html:



<div class="form-group" id="divExecutionSchedule">
<label class="control-label col-md-2" id="lblExecutionSchedule">Execution Schedule</label>
<div class="col-md-3">
<div class="input-group">
<asp:CheckboxList ID="ddlExecutionSchedule" ClientIDMode="Static" CssClass="chkLabel" runat="server" AutoPostBack="false" CellPadding="5" CellSpacing="5" RepeatDirection="Horizontal" RepeatLayout="Table" onchange="ToggleExecutionSchedule(this)" >
<asp:ListItem Text="Daily" Value="Daily"></asp:ListItem>
<asp:ListItem Text="Weekly" Value="Weekly"></asp:ListItem>
<asp:ListItem Text="Monthly" Value="Monthly"></asp:ListItem>
</asp:CheckboxList>
</div>
</div>




c#:



//if (ddlExecutionSchedule.Text == "Weekly") // <= Commented off to allow catering for multiple checkboxes to be ticked at the same time
//{
string selectedDay = item["Days"] != null ? item["Days"].ToString() : string.Empty;

if (!string.IsNullOrEmpty(selectedDay))
{
List<string> day = selectedDay.Replace(";#",";").Split(';').ToList();
for (int i = 0; i < chkSelectDay.Items.Count; i++)
{
if (day.Contains(chkSelectDay.Items[i].Value))
{
//Check only if they match!
chkSelectDay.Items[i].Selected = true;
}
}
}
//}


I have went through the similar articles, and have tried several methods, including adding in GetElementsByTagName, but hit Uncaught TypeError.



Any help is greatly appreciated.










share|improve this question

























  • What you see document.getElementById("<%=ddlExecutionSchedule.ClientID%>").length in console

    – Mamun
    Nov 15 '18 at 5:49











  • @Mamun let me check

    – gymcode
    Nov 15 '18 at 5:50














0












0








0








I have a CheckboxList with 3 options.



In my javascript, I want to check which options are ticked.



But the validation did not go through as the var value retrieved is undefined.



javascript: EDIT



var schedule = document.getElementById("<%=ddlExecutionSchedule.ClientID%>").value; 
// ^ return as undefined

var schedule2 = document.getElementById("ddlExecutionSchedule").value;
// ^ return as undefined

var scheduleOptions = schedule.getElementsByTagName('input');
// ^ error: Uncaught TypeError: Cannot read property 'getElementsByTagName' of undefined


html:



<div class="form-group" id="divExecutionSchedule">
<label class="control-label col-md-2" id="lblExecutionSchedule">Execution Schedule</label>
<div class="col-md-3">
<div class="input-group">
<asp:CheckboxList ID="ddlExecutionSchedule" ClientIDMode="Static" CssClass="chkLabel" runat="server" AutoPostBack="false" CellPadding="5" CellSpacing="5" RepeatDirection="Horizontal" RepeatLayout="Table" onchange="ToggleExecutionSchedule(this)" >
<asp:ListItem Text="Daily" Value="Daily"></asp:ListItem>
<asp:ListItem Text="Weekly" Value="Weekly"></asp:ListItem>
<asp:ListItem Text="Monthly" Value="Monthly"></asp:ListItem>
</asp:CheckboxList>
</div>
</div>




c#:



//if (ddlExecutionSchedule.Text == "Weekly") // <= Commented off to allow catering for multiple checkboxes to be ticked at the same time
//{
string selectedDay = item["Days"] != null ? item["Days"].ToString() : string.Empty;

if (!string.IsNullOrEmpty(selectedDay))
{
List<string> day = selectedDay.Replace(";#",";").Split(';').ToList();
for (int i = 0; i < chkSelectDay.Items.Count; i++)
{
if (day.Contains(chkSelectDay.Items[i].Value))
{
//Check only if they match!
chkSelectDay.Items[i].Selected = true;
}
}
}
//}


I have went through the similar articles, and have tried several methods, including adding in GetElementsByTagName, but hit Uncaught TypeError.



Any help is greatly appreciated.










share|improve this question
















I have a CheckboxList with 3 options.



In my javascript, I want to check which options are ticked.



But the validation did not go through as the var value retrieved is undefined.



javascript: EDIT



var schedule = document.getElementById("<%=ddlExecutionSchedule.ClientID%>").value; 
// ^ return as undefined

var schedule2 = document.getElementById("ddlExecutionSchedule").value;
// ^ return as undefined

var scheduleOptions = schedule.getElementsByTagName('input');
// ^ error: Uncaught TypeError: Cannot read property 'getElementsByTagName' of undefined


html:



<div class="form-group" id="divExecutionSchedule">
<label class="control-label col-md-2" id="lblExecutionSchedule">Execution Schedule</label>
<div class="col-md-3">
<div class="input-group">
<asp:CheckboxList ID="ddlExecutionSchedule" ClientIDMode="Static" CssClass="chkLabel" runat="server" AutoPostBack="false" CellPadding="5" CellSpacing="5" RepeatDirection="Horizontal" RepeatLayout="Table" onchange="ToggleExecutionSchedule(this)" >
<asp:ListItem Text="Daily" Value="Daily"></asp:ListItem>
<asp:ListItem Text="Weekly" Value="Weekly"></asp:ListItem>
<asp:ListItem Text="Monthly" Value="Monthly"></asp:ListItem>
</asp:CheckboxList>
</div>
</div>




c#:



//if (ddlExecutionSchedule.Text == "Weekly") // <= Commented off to allow catering for multiple checkboxes to be ticked at the same time
//{
string selectedDay = item["Days"] != null ? item["Days"].ToString() : string.Empty;

if (!string.IsNullOrEmpty(selectedDay))
{
List<string> day = selectedDay.Replace(";#",";").Split(';').ToList();
for (int i = 0; i < chkSelectDay.Items.Count; i++)
{
if (day.Contains(chkSelectDay.Items[i].Value))
{
//Check only if they match!
chkSelectDay.Items[i].Selected = true;
}
}
}
//}


I have went through the similar articles, and have tried several methods, including adding in GetElementsByTagName, but hit Uncaught TypeError.



Any help is greatly appreciated.







javascript c# html visual-studio checkboxlist






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 15 '18 at 7:51







gymcode

















asked Nov 15 '18 at 5:39









gymcodegymcode

1,578104486




1,578104486













  • What you see document.getElementById("<%=ddlExecutionSchedule.ClientID%>").length in console

    – Mamun
    Nov 15 '18 at 5:49











  • @Mamun let me check

    – gymcode
    Nov 15 '18 at 5:50



















  • What you see document.getElementById("<%=ddlExecutionSchedule.ClientID%>").length in console

    – Mamun
    Nov 15 '18 at 5:49











  • @Mamun let me check

    – gymcode
    Nov 15 '18 at 5:50

















What you see document.getElementById("<%=ddlExecutionSchedule.ClientID%>").length in console

– Mamun
Nov 15 '18 at 5:49





What you see document.getElementById("<%=ddlExecutionSchedule.ClientID%>").length in console

– Mamun
Nov 15 '18 at 5:49













@Mamun let me check

– gymcode
Nov 15 '18 at 5:50





@Mamun let me check

– gymcode
Nov 15 '18 at 5:50












3 Answers
3






active

oldest

votes


















2














It is returning undefined as the container of the checkbox list does not have any value so,



You need to loop through the CheckBox List to get the values of checked ones like:



Edit: As you have specified ClientIDMode="Static" so it wont be changing on runtime so, you can directly specify ID of the container



        //var chkBox = document.getElementById('<%= ddlExecutionSchedule.ClientID %>');
var chkBox = document.getElementById('ddlExecutionSchedule');
var options = chkBox.getElementsByTagName('input');
var listOfSpans = chkBox.getElementsByTagName('span'); //change 'span' as per the page structure
for (var i = 0; i < options.length; i++)
{
if(options[i].checked)
{
alert(listOfSpans[i].attributes["JSvalue"].value); //change attribute as per the page structure
}
}





share|improve this answer


























  • Can I also implement an additional check in the if statement? if ((options[i].checked) && ((options[i].value)=="Weekly"))

    – gymcode
    Nov 15 '18 at 6:51











  • Yes, absolutely you can

    – Ambrish Pathak
    Nov 15 '18 at 7:11











  • Hi, the statement var options = chkBox.getElementsByTagName('input'); is giving me error Uncaught TypeError: Cannot read property 'getElementsByTagName' of undefined.

    – gymcode
    Nov 15 '18 at 8:35











  • That is dependent on the page structure, show me the rendered code on browser or create an example on JS fiddle

    – Ambrish Pathak
    Nov 15 '18 at 8:52






  • 2





    @gymcode see this fiddle jsfiddle.net/97uk8f1r

    – Ambrish Pathak
    Nov 15 '18 at 9:03



















0














Please remove ClientIDMode="Static" from below code.



<asp:CheckboxList ID="ddlExecutionSchedule" CssClass="chkLabel" runat="server" AutoPostBack="false" CellPadding="5" CellSpacing="5" RepeatDirection="Horizontal" RepeatLayout="Table" onchange="ToggleExecutionSchedule(this)" >
<asp:ListItem Text="Daily" Value="Daily"></asp:ListItem>
<asp:ListItem Text="Weekly" Value="Weekly"></asp:ListItem>
<asp:ListItem Text="Monthly" Value="Monthly"></asp:ListItem>
</asp:CheckboxList>


or if you want to continue with ClientIDMode="Static" then write JS syntax as follow.



var schedule = document.getElementById("ddlExecutionSchedule").value;


this might help you.






share|improve this answer


























  • Hi, I changed my JS syntax, but it is still returned as undefined

    – gymcode
    Nov 15 '18 at 7:52











  • Hi, please remove ClientIDMode="Static" from checklist box.

    – Kaksh Patel
    Nov 21 '18 at 8:08



















0














Can you try removing double quotes i.e. "" around "<%=ddlExecutionSchedule.ClientID%>" in js and just keep (<%=ddlExecutionSchedule.ClientID%>).



this might help u






share|improve this answer

























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53313082%2fgetelementbyid-returns-undefined-value%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    3 Answers
    3






    active

    oldest

    votes








    3 Answers
    3






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    2














    It is returning undefined as the container of the checkbox list does not have any value so,



    You need to loop through the CheckBox List to get the values of checked ones like:



    Edit: As you have specified ClientIDMode="Static" so it wont be changing on runtime so, you can directly specify ID of the container



            //var chkBox = document.getElementById('<%= ddlExecutionSchedule.ClientID %>');
    var chkBox = document.getElementById('ddlExecutionSchedule');
    var options = chkBox.getElementsByTagName('input');
    var listOfSpans = chkBox.getElementsByTagName('span'); //change 'span' as per the page structure
    for (var i = 0; i < options.length; i++)
    {
    if(options[i].checked)
    {
    alert(listOfSpans[i].attributes["JSvalue"].value); //change attribute as per the page structure
    }
    }





    share|improve this answer


























    • Can I also implement an additional check in the if statement? if ((options[i].checked) && ((options[i].value)=="Weekly"))

      – gymcode
      Nov 15 '18 at 6:51











    • Yes, absolutely you can

      – Ambrish Pathak
      Nov 15 '18 at 7:11











    • Hi, the statement var options = chkBox.getElementsByTagName('input'); is giving me error Uncaught TypeError: Cannot read property 'getElementsByTagName' of undefined.

      – gymcode
      Nov 15 '18 at 8:35











    • That is dependent on the page structure, show me the rendered code on browser or create an example on JS fiddle

      – Ambrish Pathak
      Nov 15 '18 at 8:52






    • 2





      @gymcode see this fiddle jsfiddle.net/97uk8f1r

      – Ambrish Pathak
      Nov 15 '18 at 9:03
















    2














    It is returning undefined as the container of the checkbox list does not have any value so,



    You need to loop through the CheckBox List to get the values of checked ones like:



    Edit: As you have specified ClientIDMode="Static" so it wont be changing on runtime so, you can directly specify ID of the container



            //var chkBox = document.getElementById('<%= ddlExecutionSchedule.ClientID %>');
    var chkBox = document.getElementById('ddlExecutionSchedule');
    var options = chkBox.getElementsByTagName('input');
    var listOfSpans = chkBox.getElementsByTagName('span'); //change 'span' as per the page structure
    for (var i = 0; i < options.length; i++)
    {
    if(options[i].checked)
    {
    alert(listOfSpans[i].attributes["JSvalue"].value); //change attribute as per the page structure
    }
    }





    share|improve this answer


























    • Can I also implement an additional check in the if statement? if ((options[i].checked) && ((options[i].value)=="Weekly"))

      – gymcode
      Nov 15 '18 at 6:51











    • Yes, absolutely you can

      – Ambrish Pathak
      Nov 15 '18 at 7:11











    • Hi, the statement var options = chkBox.getElementsByTagName('input'); is giving me error Uncaught TypeError: Cannot read property 'getElementsByTagName' of undefined.

      – gymcode
      Nov 15 '18 at 8:35











    • That is dependent on the page structure, show me the rendered code on browser or create an example on JS fiddle

      – Ambrish Pathak
      Nov 15 '18 at 8:52






    • 2





      @gymcode see this fiddle jsfiddle.net/97uk8f1r

      – Ambrish Pathak
      Nov 15 '18 at 9:03














    2












    2








    2







    It is returning undefined as the container of the checkbox list does not have any value so,



    You need to loop through the CheckBox List to get the values of checked ones like:



    Edit: As you have specified ClientIDMode="Static" so it wont be changing on runtime so, you can directly specify ID of the container



            //var chkBox = document.getElementById('<%= ddlExecutionSchedule.ClientID %>');
    var chkBox = document.getElementById('ddlExecutionSchedule');
    var options = chkBox.getElementsByTagName('input');
    var listOfSpans = chkBox.getElementsByTagName('span'); //change 'span' as per the page structure
    for (var i = 0; i < options.length; i++)
    {
    if(options[i].checked)
    {
    alert(listOfSpans[i].attributes["JSvalue"].value); //change attribute as per the page structure
    }
    }





    share|improve this answer















    It is returning undefined as the container of the checkbox list does not have any value so,



    You need to loop through the CheckBox List to get the values of checked ones like:



    Edit: As you have specified ClientIDMode="Static" so it wont be changing on runtime so, you can directly specify ID of the container



            //var chkBox = document.getElementById('<%= ddlExecutionSchedule.ClientID %>');
    var chkBox = document.getElementById('ddlExecutionSchedule');
    var options = chkBox.getElementsByTagName('input');
    var listOfSpans = chkBox.getElementsByTagName('span'); //change 'span' as per the page structure
    for (var i = 0; i < options.length; i++)
    {
    if(options[i].checked)
    {
    alert(listOfSpans[i].attributes["JSvalue"].value); //change attribute as per the page structure
    }
    }






    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Nov 15 '18 at 7:17

























    answered Nov 15 '18 at 6:13









    Ambrish PathakAmbrish Pathak

    2,4681623




    2,4681623













    • Can I also implement an additional check in the if statement? if ((options[i].checked) && ((options[i].value)=="Weekly"))

      – gymcode
      Nov 15 '18 at 6:51











    • Yes, absolutely you can

      – Ambrish Pathak
      Nov 15 '18 at 7:11











    • Hi, the statement var options = chkBox.getElementsByTagName('input'); is giving me error Uncaught TypeError: Cannot read property 'getElementsByTagName' of undefined.

      – gymcode
      Nov 15 '18 at 8:35











    • That is dependent on the page structure, show me the rendered code on browser or create an example on JS fiddle

      – Ambrish Pathak
      Nov 15 '18 at 8:52






    • 2





      @gymcode see this fiddle jsfiddle.net/97uk8f1r

      – Ambrish Pathak
      Nov 15 '18 at 9:03



















    • Can I also implement an additional check in the if statement? if ((options[i].checked) && ((options[i].value)=="Weekly"))

      – gymcode
      Nov 15 '18 at 6:51











    • Yes, absolutely you can

      – Ambrish Pathak
      Nov 15 '18 at 7:11











    • Hi, the statement var options = chkBox.getElementsByTagName('input'); is giving me error Uncaught TypeError: Cannot read property 'getElementsByTagName' of undefined.

      – gymcode
      Nov 15 '18 at 8:35











    • That is dependent on the page structure, show me the rendered code on browser or create an example on JS fiddle

      – Ambrish Pathak
      Nov 15 '18 at 8:52






    • 2





      @gymcode see this fiddle jsfiddle.net/97uk8f1r

      – Ambrish Pathak
      Nov 15 '18 at 9:03

















    Can I also implement an additional check in the if statement? if ((options[i].checked) && ((options[i].value)=="Weekly"))

    – gymcode
    Nov 15 '18 at 6:51





    Can I also implement an additional check in the if statement? if ((options[i].checked) && ((options[i].value)=="Weekly"))

    – gymcode
    Nov 15 '18 at 6:51













    Yes, absolutely you can

    – Ambrish Pathak
    Nov 15 '18 at 7:11





    Yes, absolutely you can

    – Ambrish Pathak
    Nov 15 '18 at 7:11













    Hi, the statement var options = chkBox.getElementsByTagName('input'); is giving me error Uncaught TypeError: Cannot read property 'getElementsByTagName' of undefined.

    – gymcode
    Nov 15 '18 at 8:35





    Hi, the statement var options = chkBox.getElementsByTagName('input'); is giving me error Uncaught TypeError: Cannot read property 'getElementsByTagName' of undefined.

    – gymcode
    Nov 15 '18 at 8:35













    That is dependent on the page structure, show me the rendered code on browser or create an example on JS fiddle

    – Ambrish Pathak
    Nov 15 '18 at 8:52





    That is dependent on the page structure, show me the rendered code on browser or create an example on JS fiddle

    – Ambrish Pathak
    Nov 15 '18 at 8:52




    2




    2





    @gymcode see this fiddle jsfiddle.net/97uk8f1r

    – Ambrish Pathak
    Nov 15 '18 at 9:03





    @gymcode see this fiddle jsfiddle.net/97uk8f1r

    – Ambrish Pathak
    Nov 15 '18 at 9:03













    0














    Please remove ClientIDMode="Static" from below code.



    <asp:CheckboxList ID="ddlExecutionSchedule" CssClass="chkLabel" runat="server" AutoPostBack="false" CellPadding="5" CellSpacing="5" RepeatDirection="Horizontal" RepeatLayout="Table" onchange="ToggleExecutionSchedule(this)" >
    <asp:ListItem Text="Daily" Value="Daily"></asp:ListItem>
    <asp:ListItem Text="Weekly" Value="Weekly"></asp:ListItem>
    <asp:ListItem Text="Monthly" Value="Monthly"></asp:ListItem>
    </asp:CheckboxList>


    or if you want to continue with ClientIDMode="Static" then write JS syntax as follow.



    var schedule = document.getElementById("ddlExecutionSchedule").value;


    this might help you.






    share|improve this answer


























    • Hi, I changed my JS syntax, but it is still returned as undefined

      – gymcode
      Nov 15 '18 at 7:52











    • Hi, please remove ClientIDMode="Static" from checklist box.

      – Kaksh Patel
      Nov 21 '18 at 8:08
















    0














    Please remove ClientIDMode="Static" from below code.



    <asp:CheckboxList ID="ddlExecutionSchedule" CssClass="chkLabel" runat="server" AutoPostBack="false" CellPadding="5" CellSpacing="5" RepeatDirection="Horizontal" RepeatLayout="Table" onchange="ToggleExecutionSchedule(this)" >
    <asp:ListItem Text="Daily" Value="Daily"></asp:ListItem>
    <asp:ListItem Text="Weekly" Value="Weekly"></asp:ListItem>
    <asp:ListItem Text="Monthly" Value="Monthly"></asp:ListItem>
    </asp:CheckboxList>


    or if you want to continue with ClientIDMode="Static" then write JS syntax as follow.



    var schedule = document.getElementById("ddlExecutionSchedule").value;


    this might help you.






    share|improve this answer


























    • Hi, I changed my JS syntax, but it is still returned as undefined

      – gymcode
      Nov 15 '18 at 7:52











    • Hi, please remove ClientIDMode="Static" from checklist box.

      – Kaksh Patel
      Nov 21 '18 at 8:08














    0












    0








    0







    Please remove ClientIDMode="Static" from below code.



    <asp:CheckboxList ID="ddlExecutionSchedule" CssClass="chkLabel" runat="server" AutoPostBack="false" CellPadding="5" CellSpacing="5" RepeatDirection="Horizontal" RepeatLayout="Table" onchange="ToggleExecutionSchedule(this)" >
    <asp:ListItem Text="Daily" Value="Daily"></asp:ListItem>
    <asp:ListItem Text="Weekly" Value="Weekly"></asp:ListItem>
    <asp:ListItem Text="Monthly" Value="Monthly"></asp:ListItem>
    </asp:CheckboxList>


    or if you want to continue with ClientIDMode="Static" then write JS syntax as follow.



    var schedule = document.getElementById("ddlExecutionSchedule").value;


    this might help you.






    share|improve this answer















    Please remove ClientIDMode="Static" from below code.



    <asp:CheckboxList ID="ddlExecutionSchedule" CssClass="chkLabel" runat="server" AutoPostBack="false" CellPadding="5" CellSpacing="5" RepeatDirection="Horizontal" RepeatLayout="Table" onchange="ToggleExecutionSchedule(this)" >
    <asp:ListItem Text="Daily" Value="Daily"></asp:ListItem>
    <asp:ListItem Text="Weekly" Value="Weekly"></asp:ListItem>
    <asp:ListItem Text="Monthly" Value="Monthly"></asp:ListItem>
    </asp:CheckboxList>


    or if you want to continue with ClientIDMode="Static" then write JS syntax as follow.



    var schedule = document.getElementById("ddlExecutionSchedule").value;


    this might help you.







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Nov 15 '18 at 7:11









    Ashish Kamble

    718619




    718619










    answered Nov 15 '18 at 6:58









    Kaksh PatelKaksh Patel

    246




    246













    • Hi, I changed my JS syntax, but it is still returned as undefined

      – gymcode
      Nov 15 '18 at 7:52











    • Hi, please remove ClientIDMode="Static" from checklist box.

      – Kaksh Patel
      Nov 21 '18 at 8:08



















    • Hi, I changed my JS syntax, but it is still returned as undefined

      – gymcode
      Nov 15 '18 at 7:52











    • Hi, please remove ClientIDMode="Static" from checklist box.

      – Kaksh Patel
      Nov 21 '18 at 8:08

















    Hi, I changed my JS syntax, but it is still returned as undefined

    – gymcode
    Nov 15 '18 at 7:52





    Hi, I changed my JS syntax, but it is still returned as undefined

    – gymcode
    Nov 15 '18 at 7:52













    Hi, please remove ClientIDMode="Static" from checklist box.

    – Kaksh Patel
    Nov 21 '18 at 8:08





    Hi, please remove ClientIDMode="Static" from checklist box.

    – Kaksh Patel
    Nov 21 '18 at 8:08











    0














    Can you try removing double quotes i.e. "" around "<%=ddlExecutionSchedule.ClientID%>" in js and just keep (<%=ddlExecutionSchedule.ClientID%>).



    this might help u






    share|improve this answer






























      0














      Can you try removing double quotes i.e. "" around "<%=ddlExecutionSchedule.ClientID%>" in js and just keep (<%=ddlExecutionSchedule.ClientID%>).



      this might help u






      share|improve this answer




























        0












        0








        0







        Can you try removing double quotes i.e. "" around "<%=ddlExecutionSchedule.ClientID%>" in js and just keep (<%=ddlExecutionSchedule.ClientID%>).



        this might help u






        share|improve this answer















        Can you try removing double quotes i.e. "" around "<%=ddlExecutionSchedule.ClientID%>" in js and just keep (<%=ddlExecutionSchedule.ClientID%>).



        this might help u







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Nov 15 '18 at 7:39









        Ashish Kamble

        718619




        718619










        answered Nov 15 '18 at 6:32









        Pratik RathiPratik Rathi

        66




        66






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53313082%2fgetelementbyid-returns-undefined-value%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Florida Star v. B. J. F.

            Danny Elfman

            Retrieve a Users Dashboard in Tumblr with R and TumblR. Oauth Issues