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 8377199
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T15:36:29+00:00 2026-06-09T15:36:29+00:00

I am creating a data entry form for a school. The school will be

  • 0

I am creating a data entry form for a school. The school will be entering data in this database for their 5th till 12th grade students. Now 5th grade has 4 sections and all other grade has 3 sections. 10th grade has only one section.

The form is ready and using jquery i am able to make the section select element either show or hide depending on the grade the user selects. My problem is when the user selects std as 5th the section select element is shown and the user selects say “A” and submits. But the value i get is 0. If the user selects section as “D” , the value being sent is “B”.

The section select for all other grades are working fine, this problem arises only when the grade selected is 5th.

Script

<script type='text/javascript' src='scripts/jquery-1.5.2.js'></script>
<script type="text/javascript">//<![CDATA[ 
$(window).load(function(){
$("#std").change(function() {
        var value = $(this).val();
        if(parseInt(value)==0) {
           $("#sec5").hide();
           $("#sec6").hide();
        }
        if(parseInt(value)==5) {
            $("#sec5").show();
            $("#sec6").hide();
        }
        if(parseInt(value)==6) {
           $("#sec5").hide();
           $("#sec6").show();
        }
        if(parseInt(value)==7) {
           $("#sec5").hide();
           $("#sec6").show();
        } 
    if(parseInt(value)==6) {
       $("#sec5").hide();
       $("#sec6").show();
    }
    if(parseInt(value)==8) {
       $("#sec5").hide();
       $("#sec6").show();
    }
    if(parseInt(value)==9) {
       $("#sec5").hide();
       $("#sec6").show();
    }
    if(parseInt(value)==10) {
       $("#sec5").hide();
       $("#sec6").hide();
    }
    if(parseInt(value)==11) {
       $("#sec5").hide();
       $("#sec6").show();
    }
    if(parseInt(value)==12) {
       $("#sec5").hide();
       $("#sec6").show();
    }
});

});//]]> 
</script>

HTML Part

<form action="check.php" method="post">
    <fieldset>
      <legend>DBMS</legend>
      <label for="roll">Roll:
        <input name="roll" type="text" id="roll" value="" size="8" maxlength="10" />
      </label>
      &nbsp;
      <label for="marks">Total Marks:
        <input name="marks" type="text" id="marks" value="" size="3" maxlength="3" />
      </label>
      &nbsp;
      <label for="std">Std</label>
      <select id="std" name="std">
        <option value="0">--Select--</option>
        <option value="5">5</option>
        <option value="6">6</option>
        <option value="7">7</option>
        <option value="8">8</option>
        <option value="9">9</option>
        <option value="10">10</option>
        <option value="11">11</option>
        <option value="12">12</option>
      </select>
      <span id="sec5" class="hide">
      &nbsp;
      <label for="sec">Section</label>
      <select id="sec" name="sec">
        <option value="0">--Select--</option>
        <option value="A">Sec A</option>
        <option value="B">Sec B</option>
        <option value="C">Sec C</option>
        <option value="D">Sec D</option>
      </select>
      </span> <span id="sec6" class="hide">
      &nbsp;
      <label for="sec">Section</label>
      <select id="sec" name="sec">
        <option value="0">--Select--</option>
        <option value="A">Sec A</option>
        <option value="B">Sec B</option>
        <option value="C">Sec C</option>
      </select>
      </span>
      <p align="center">
        <input type="submit" name="nlogin" id="nlogin" value="Submit" />
        &nbsp;
        <input type="reset" name="nreset" id="nreset" value="Reset" />
      </p>
    </fieldset>
  </form>
  • 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-06-09T15:36:30+00:00Added an answer on June 9, 2026 at 3:36 pm

    When you show() or hide() one area of the form, it isn’t removed — just hidden from sight. So your form is actually submitting two select dropdowns with the name (and ID — a big no-no) of sec. Your problem is caused by the second select’s value overwriting the first.

    It’s possible to solve this by remove()ing one of the dropdowns, but that wouldn’t be reversible and I wouldn’t recommend it.

    Instead, you might change the name/ID of at least one of those select dropdowns — say, sec1 and sec2 — and add some server-side code to see which one should be processed.

    A second solution might be to just have one select in your HTML and use jQuery to modify its options. This will require rewriting most of your JavaScript code, but it will eliminate the need for server-side coding. (However, server-side validation is ALWAYS a good idea in these cases, as a redundancy, and should be implemented anyway.) Something like:

    <select id="sec" name="sec">
        <option value="0">--Select--</option>
        <option id="sec-a" value="A">Sec A</option>
        <option id="sec-b" value="B">Sec B</option>
        <option id="sec-c" value="C">Sec C</option>
        <option id="sec-d" value="D">Sec D</option>
      </select>
    

    JS:

    $("#std").change(function() {
        var v = parseInt($(this).val(), 10); // always use a radix
        if(v==0) {
            $('#sec').hide();
        } else if(v==5) {
            $('#sec').show();
            $('#sec-d').hide();
        } else if(v==6) {
            $('#sec').show();
            $('#sec-d').show();
        }  // etc.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm creating a browser based QC/data entry app that will let people edit OCRed
Creating a relatively simple data entry form, and just want to separate certain sections
I have a Django form that will add an entry to a database with
I am creating a spread sheet to help ease the entry of data into
I'm creating a data-entry application where users are allowed to create the entry schema.
I have mastered creating custom data types and adding fields with CCK. Then I
I'm creating test data for a Rails app. How do I define the value
I'm creating a data model using xcode and core data. It's an object graph,
Jython is great for creating custom data structures on need basis, but how to
I am creating a Core Data application where: category entity has the following attributes

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.