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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:57:54+00:00 2026-05-28T04:57:54+00:00

I’m am attempting to get the value of one input in a table row

  • 0

I’m am attempting to get the value of one input in a table row IF one of the other cells in the row has a value. The goal here is, if the user entered money received into the row, then a received date is required. So, on submit I want to look through all the rows and check for an entry in the current cell, then check for a date in the date cell. There are more than one row for payment entry. Here is the HTML:

       <div class="new_payments">
        <tr>
            <td>
                <input type="text" 
                name="new_payments[<?php echo $s ?>][payment_date]"
                class="payment_date" 
                size='10' maxlength="10" 
                > 
            </td>                                
            <td>                            
                <input type="text" 
                name="new_payments[<?php echo $s ?>][credit_card]"
                class="credit_received"                               
                size="8">
            </td>  
            <td>
                <input type="text" 
                name="new_payments[<?php echo $s ?>][check]"
                class="check_received" 
                size="8">            
            </td>
            <td>
                <input type="text"  
                name="new_payments[<?php echo $s ?>][cash]"
                class="cash_received" 
                size="8">             
            </td>
        </tr>
    </div>

Here is the jQuery I am using (haven’t added the check for a value in ‘this’ yet) to see if I am getting the expected result. Sadly, I’m getting ‘undefined’:

    jQuery('input:text.cash_received').each (function() {
       var $theDate  = jQuery(this).closest('div.new_payments').find('.payment_date').attr('value');
       alert('the closest date value is ' + $theDate );
}); 

I thought I understood the concept of go up to the parent then find the element you’re looking for. Apparently not? Thanks for your excellent help!

  • 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-28T04:57:55+00:00Added an answer on May 28, 2026 at 4:57 am

    this is tested and working. it will only alert if .cash_received has a value. i added values to the inputs for testing. also note the removal of the div wrapper. i added the class to the TR

    jQuery(document).ready(function(){
        jQuery('input[type=text][value!=""].cash_received').each (function() {
            var myval= jQuery(this).parents('.new_payments').find('.payment_date').val();
               alert('the closest date value is ' +myval);
        });
    });
    
    
    
        <tr class="new_payments">
            <td>
                <input type="text" 
                name="new_payments[<?php echo $s ?>][payment_date]"
                class="payment_date" value='this should alert'
                size='10' maxlength="10" 
                > 
            </td>                                
            <td>                            
                <input type="text" 
                name="new_payments[<?php echo $s ?>][credit_card]"
                class="credit_received"                               
                size="8">
            </td>  
            <td>
                <input type="text" 
                name="new_payments[<?php echo $s ?>][check]"
                class="check_received"
                size="8">            
            </td>
            <td>
                <input type="text"  
                name="new_payments[<?php echo $s ?>][cash]"
                class="cash_received" value='this input has a value'
                size="8">             
            </td>
        </tr>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I need to clean up various Word 'smart' characters in user input, including but
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I am reading a book about Javascript and jQuery and using one of the
In my XML file chapters tag has more chapter tag.i need to display chapters

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.