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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T20:17:19+00:00 2026-06-12T20:17:19+00:00

my first question. Also my english is far form being something I can describe

  • 0

my first question. Also my english is far form being something I can describe as good, so please be forgiving (don’t know better word :)).

I am using php to generate table rows with diffrent style.

if ($n % 2 == 0)
    $tr_class = ' class="package_' . $p->package_id . ' alt"';
else {
    $tr_class = ' class="package_' . $p->package_id . '"';
}

<tr<?php echo $tr_class ?>

I want to select input field in fifth cell in each row that has class package_{number here} and add some styles to it.
To do so, I use that statement:

$('tr.package_' + package_errors_ids[i] + ' td:nth-child(5) input[type=text]').css('border', '1px solid red');

But second class (.alt) does not allow me to do this.
I don’t know how to modify that statement do achieve this.
Will you help? 🙂

I forgot to write it. It works but not everytime. Package_errors_ids is array containing numbers I use to create unique IDs for distinguish for user invalid packages. When 2 rows are invalid (one has .alt class), both are affected by this code css('border', '1px solid red');. But when one is valid, non of these rows are affected.

EDIT:
I’ve simplified my mixed js and php code in order to generate code without using JavaScript array
http://jsfiddle.net/TAdsT/7/

After this simplification and clearing my webbrowser cache, it works properly! Thank you all for your input. Here’s the code (if jsfindle.net erase it):

<script type="text/javascript">
$(document).ready(function() {
<?php
$count = count($this->package_errors_ids);
if ($count > 0)
{
    for ($i = 0; $i < $count; $i++)
    {
        echo "$('tr.package_" .
            (int) $this->package_errors_ids[$i] .
            " td:nth-child(5) input[type=\"text\"]').css('border', '1px solid red');\n";
    }
}
?>
});
</script>
  • 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-12T20:17:20+00:00Added an answer on June 12, 2026 at 8:17 pm

    I’m looking at this:

    // in PHP
    $('tr.package_' + package_errors_ids[i] + ' td:nth-child(5) input[type=text]')
    

    That will generate something like this, I assume:

    // after PHP
    $('tr.package_1 td:nth-child(5) input[type=text]')
    

    That won’t have any problems at all in selecting a <tr class="package_1 alt">. No trouble at all. Assuming your HTML is getting generated correctly, that means you’re doing something else wrong. And I’m going to assume that it’s this part:

    input[type=text]
    

    Try changing that to

    input[type="text"]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know the question header sounds weird, but since English is not my first
First question is, given a url to an mp4 video, how can I save
First of all, sorry for my English I'm not good at it but I
First of all, please excuse any typo, English is not my native language. Here's
First of all, please excuse any typo as English is not my native language.
This is my first question on this forum and I hope u don't blame
(my first question!) Can anyone tell me why, in winforms, layered transparent regions lose
My first question so please be kind. I am having problems with my installer
my first question here: I've searched the internet and also read several question and
First question on Stackoverflow (.Net 2.0): So I am trying to return an XML

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.