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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T23:36:12+00:00 2026-05-23T23:36:12+00:00

I have a form that has a select menu(A) and 2 divs (B and

  • 0

I have a form that has a select menu(A) and 2 divs (B and C) and an input type of text (D).
I would like to have the select menu drop down(A) selections affect the value that get shown in div B.Then when a user enters a value in the text element D,the value is compared to the value in B and C would output (show) wether the value is big or small than that in B.

So far I have been using the jquery blur function and its proving inconsistent

$('.expCheck').blur(function() {
    var curr = $(this).val();
    var prevField = parseInt($(this).parent().prev('td').children('.getValue').text());
    var compField = $(this).parent().next('td').children('.compCheck');
    compField.css('background-color','#c00');

    if (curr < prevField) {
        compField.css('background-color','#c00').text('Failed');
    } else {
        compField.css('background-color','#0c0').text('Passed'); 
    }
});

the html structure

<form method="post" enctype="multipart/form-data" name="testForm" id="testForm" action="test_process.php">
    <select name="day_select" id="day_select" class="daychanger">
        <option value="0">--Please Select Days--</option>
        <option value="1">1- 7 Days</option>
        <option value="2">8-14 Days</option>
        <option value="3">15-21 Days</option>
    </select>

    <table class="mtbl">
        <tr class="head">
            <td width="297">&nbsp;</td>
            <td width="297">Required Days</td>
            <td width="246">Your Days</td>
            <td width="246">Status</td>
        </tr>
        <tr class="info'>
            <td>Days </td>
            <td>
                <div id="v1" class="getValue"></div>
            </td>
            <td align="left">
                <input class="expCheck" name="days" type="text" id="days" size="5"  maxlength="5" />
            </td>
            <td>
                <div class="compCheck"></div>
            </td>
        </tr>
    </table>
</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-05-23T23:36:12+00:00Added an answer on May 23, 2026 at 11:36 pm

    The business requirements are not clear enough…

    1. What goes in the Required Days column?

    2. Why not put the <select> control in that column?

    3. Should the user’s days be compared against the range, that is be between 1 and 7, or 8 and 14, etc? (Right now, the logic just checks against the max.)

    4. Will there always be just one form per page?

    5. Will there always be just one line per form? The code can be simplified a fair bit, if so. Otherwise the logic and form structure will need to be tweaked.

    Anyway, See this live demo, based on the best guess as the question stands now.

    Note that the HTML is slightly changed: Fixed a couple typos and changed the <option> values to match business logic.

    The adjusted HTML is:

    <form method="post" enctype="multipart/form-data" name="testForm" id="testForm" action="test_process.php">
        <select name="day_select" id="day_select" class="daychanger">
            <option value="0">--Please Select Days--</option>
            <option value="7">1- 7 Days</option>
            <option value="14">8-14 Days</option>
            <option value="21">15-21 Days</option>
        </select>
        <table class="mtbl">
            <tr class="head">
                <td width="297">&nbsp;</td>
                <td width="297">Required Days</td>
                <td width="246">Your Days</td>
                <td width="246">Status</td>
            </tr>
            <tr class="info">
                <td>Days</td>
                <td><div id="v1" class="getValue"></div></td>
                <td align="left"><input class="expCheck" name="days" type="text" id="days" size="5" maxlength="5"/></td>
                <td><div class="compCheck"></div></td>
            </tr>
        </table>
    </form>
    

    The JS / jQuery is:

    function updateStatus () {
        var maxReqDays  = parseInt ( $('#testForm table.mtbl tr.info div.getValue').text (), 10 );
        var minReqDays  = maxReqDays - 6;
        var userDays    = parseInt ( $('#days').val (), 10 );
        var statusNode  = $('#testForm > table.mtbl tr.info div.compCheck');
    
        if (userDays && maxReqDays) {
            if (userDays < maxReqDays) {
                statusNode.css ('background-color', '#c00').text ('Failed');
            } else {
                statusNode.css ('background-color', '#0c0').text ('Passed');
            }
        }
        else {
            statusNode.css ('background-color', '#ffc').text ('tbd');
        }
    }
    
    $("#day_select").change ( function () {
        var selectVal   = $(this).val ();
        if (selectVal == 0)
            selectVal   = '»select«';
    
        $('tr.info div.getValue').each ( function () { $(this).text (selectVal); } );
        updateStatus ();
    } );
    
    $('.expCheck').bind ('blur change keydown keyup mouseup', function () {
        updateStatus ();
    } );
    
    //--- Init the "Required days" cell.
    $("#day_select").change ();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have a form that has a multiple select drop down. a user can
Usage: I have a form that has a select drop-down that's controlled by another
I have a form that has multiple select drop downs. i.e. Item 1: <select
I have a contact form that has a drop-down for referral source. If Magazine
I have a form that has a file input control: <input type=file onclick=this.blur() name=descFile
I need to have a drop-down menu that allows you to select a year
So I have a form that has a listbox that shows like a ledger.
I have a CRUD form that has a select widget. The options in the
I have a simple PHP script with a form that has two select fields,
i have a form that has select element <select name=adddisplaypage[] id=adddisplaypage multiple=multiple> <option value=all

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.