Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5954229
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T17:56:28+00:00 2026-05-22T17:56:28+00:00

I have javascript that controls certain div tags that hide or show upon checked

  • 0

I have javascript that controls certain div tags that hide or show upon checked state. I then pass these values when i submit form. Thing is, values from fields in the div tag that were hidden get passed as well. How do i not pass these values?

My HTML / Javascript is as follows :

<div id="divShortAnswerQuestion">
    <h2>Short Answer Question</h2>
    <!--Question Order-->
    <asp:Label ID="Label2" runat="server" Text="Question Order"></asp:Label>
    <%=Html.TextBox("QuestionOrder")%>
    <br />
    <!--Partial Answers-->
    <asp:Label ID="Label5" runat="server" Text="Allow Partial Answers"></asp:Label>    
    <%=Html.RadioButton("PartialAnswers", "1", true) %>Yes
    <%=Html.RadioButton("PartialAnswers", "0", false) %>No
    <br />
    <!--Max Answers-->
    <asp:Label ID="Label6" runat="server" Text="Max Answers (1-10)"></asp:Label> 
    <%=Html.TextBox("Max") %>
    <br />         
    <!--Data Type-->
    <asp:Label ID="Label7" runat="server" Text="Data Type"></asp:Label>
    <%=Html.DropDownList("DataType", new List<SelectListItem>
                     {
                        new SelectListItem{Text="Numeric", Value = "Numeric"}, 
                        new SelectListItem{Text="Alphanumeric", Value = "Alphanumeric"},
                        new SelectListItem{Text="Date", Value = "Date"}
                     }) %>
    <br />
    <!--Question Type-->                         
    <asp:Label ID="Label13" runat="server" Text="Question Type"></asp:Label>
    <%=Html.DropDownList("QuestionType", new List<SelectListItem>
                     {
                        new SelectListItem{Text="Numeric", Value = "6"}, 
                        new SelectListItem{Text="Alphanumeric", Value = "7"}                                                                                  
                     }) %>
</div>

And my Javascript is something like:

$("input:radio[@name=QuestionGroup]").click(function() {
    var checkedvalue = $(this).val();
    if(checkedvalue=="1"){
        $('#divShortAnswerQuestion').hide();
        $('#divMultipleChoiceQuestion').show();
        $('#divParticipantListQuestion').hide();
    }
    if(checkedvalue=="2"){
        $('#divMultipleChoiceQuestion').hide();
        $('#divShortAnswerQuestion').show();
        $('#divParticipantListQuestion').hide();
    }
    if(checkedvalue=="3"){
        $('#divMultipleChoiceQuestion').hide();
        $('#divShortAnswerQuestion').hide();
        $('#divParticipantListQuestion').show();
    }            
});

So how would one go about not passing empty or any elements in a hidden div tag on a form submit?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T17:56:29+00:00Added an answer on May 22, 2026 at 5:56 pm

    In addition to hiding the div you could disable the input elements inside it and they will not be sent to the server:

    $('#divMultipleChoiceQuestion').hide();
    $('#divMultipleChoiceQuestion :input').attr('disabled', 'disabled');
    

    Don’t forget to re-enable them when you show the div:

    $('#divMultipleChoiceQuestion').show();
    $('#divMultipleChoiceQuestion :input').removeAttr('disabled');
    

    You could write a plugin that will do this to avoid repeating the code all over again, so that all you need to do is:

    $('#divMultipleChoiceQuestion').toggleVisibility();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a page that includes javascript which I only want to run under
I am currently using javascript to enable changes to css on hover for certain
I have an Asp.net page which requires certain sections to be partially updated automatically
I have a gridview which contains a textbox control. I need to show the
Basically I want to load a HTML document and using controls such as multiple
We have a network camera. It has an HTTP server to provides the current
I'm looking to create the storyboard idea that oDesk uses on http://www.odesk.com/w/odesk_story I like
A short way of asking this question is, how should be I go about
 my web site structure is like this :     1- master page with stylesheet and
Anyone know how you can call a functional equivalent to Html.EditorFor() from the Controller?

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.