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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T19:33:38+00:00 2026-05-21T19:33:38+00:00

I want to perform an if statement based upon the value of a hidden

  • 0

I want to perform an if statement based upon the value of a hidden input within myform.

the scenario is that I have a table consisting of tests. Each test is essentially its own form. the hidden input basically contains ‘YES’ if the test has a password attached. I want to prompt the user to enter the password if that is the case when they attempt to execute a particular test (submit the form).

so here is my code I am attempting:

$("#submit").live('click', function(event) {
    if ($(this).parent().find(':input:hidden[name=has_password]').val() == 'YES') {
            $('.messagepop').remove();
                $(this).parent().append('<div class="messagepop pop"><p><label for="password">Enter test password</label><input type="text" size="30" name="pass" id="pass" /></p><p><input type="button" id="submitPass" value="GO" id="pass_submit"/> or <a class="close" href="/">Cancel</a></p></div>');
                $(".pop").slideFadeToggle(function() { 
                $("#pass").focus();
                });
                return false;
    }  
});

Without the if statement the code works: on clicking a particular button within a form, another small password entry form pops up. However I only want the form to pop up if a value of a hidden input is ‘YES’.

I have checked that values are present in the hidden input.

I imagine I am using the jQuery slightly wrong as I am a beginner. So can somebody identify a better way of performing the check?

Many thanks,

EDIT (jsfiddle with html etc):

jsfiddle

  • 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-21T19:33:39+00:00Added an answer on May 21, 2026 at 7:33 pm

    Your HTML is extremely malformed. The <tr> and <form> end-tags are mismatched, you’ve got a <form> tag directly inside the <tr>, which is not allowed, you haven’t self-closed your <input /> tags and you have duplicate id’s on the same page.

    <tr>
      <form name='myform' method='post' action='test_sim.php'>
        <input name='test' type='hidden' value='1'>
        <input type='hidden' name='has_password' value='NO'>
        <td>TEST 1</td>
        <td>B352</td>
        <td>10</td>
        <td>2011-05-12 06:00:00</td>
        <td>2011-05-12 12:00:00</td>
        <td>06:00:00</td>
        <td><input id='submit' type='button' value='execute test'></td>
      </tr>
    </form>
    

    It should be like this:

    <tr>
      <td>TEST 1</td>
      <td>B352</td>
      <td>10</td>
      <td>2011-05-12 06:00:00</td>
      <td>2011-05-12 12:00:00</td>
      <td>06:00:00</td>
      <td>
        <form name='myform' method='post' action='test_sim.php'>
          <input name='test' type='hidden' value='1' />
          <input type='hidden' name='has_password' value='NO' />
          <input class='submit' type='button' value='execute test' />
        </form>
      </td>
    </tr>
    

    Fixing the HTML solves your problem: http://jsfiddle.net/brianpeiris/ezFgU/16/

    You should use the W3C Validator tool to check your HTML so that you can prevent these types of issues.

    Edit: As mcgrailm mentioned, your id attributes are duplicated. jQuery is forgiving here, it seems, that’s why the above jsFiddle works. You should use a class to identify your submit buttons and use the corresponding $('.submit') selector to attach a click handler.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a query I need to perform on a table that is roughly
I want to perform a 'SELECT' statement with a byte array (binary) parameter as
I have a tabBar with 4 tabs on it, and I want to perform
If I have a list of ID's that I have selected from a statement
I have models for Products and Statement_Sales and want to perform various Sum and
I want to take a poorly designed SQL statement that's embedded in C# code
I'm using postgres (postgis) and i want to perform a query that returns all
I have a date input that requires the user to enter the date in
I want to perform a set of tests in my code that are similar
i have technical wondering here guys , switch statement performs faster ,that thing i

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.