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

  • Home
  • SEARCH
  • 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 4627328
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T03:33:08+00:00 2026-05-22T03:33:08+00:00

This is a part fo php code, which use the contentArray, which is a

  • 0

This is a part fo php code, which use the contentArray, which is a JSON, and generate the UI to the user, it generate html tags, also, it generate js code too…. It works, but I think the code is pretty difficult to read and maintain, any ideas??? thank you.

for($i = 0; $i < count($contentArray); $i++){  

    if($i %2 == 0){
       echo ("<li class='even_row'>");
    }else{
       echo ("<li class='odd_row'>");
    }  
    $content = $contentArray[$i];    

    echo("<textarea class='userdata' id='user_data_textarea_".$content->{'m_sId'}."'>");
    echo($content->{'m_sDataContent'});  
    echo("</textarea>"); 

echo("</li>");   

    echo("<script type='text/javascript'>");

    echo("$('#user_data_textarea_".$content->{'m_sId'}."').bind('keydown', function(e){");  
    echo("  TypingHandler.handleTypingInUserDataTextArea(".$content->{'m_sId'}.", e);");
    echo(" });");    

    echo("</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-05-22T03:33:09+00:00Added an answer on May 22, 2026 at 3:33 am

    first for your odd and even styling there is not need for a class just use css

    here is info on that

    then in php only echo what you need in one line

    $count = count($contentArray);
    for($i = 0; $i < $count; $i++){  
        $content = $contentArray[$i];    
        echo('<li><textarea class="userdata" id="user_data_textarea_"'.$content->{'m_sId'}.'">'.$content->{'m_sDataContent'}.'</textarea></li>');   
    }
    

    and lets put the jquery in the html page away from php

    we get can get every item by using starts with selector

    $('[id^=user_data_textarea_]').bind('keydown', function(e){  
        var id = this.id.str_replace("user_data_textarea","");
        TypingHandler.handleTypingInUserDataTextArea(id, e);
    });    
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need a fix for this. here is just part of my code <?php
This part of my code works fine: #include <stdio.h> int main(){ //char somestring[3] =
I'm making a form (html & php) which is part of an admin section
It seems that this part of my code is where the exception occurs: c
I am trying to learn and writting this part of code. while testing few
I just started learning C but I don't understand this part of the code.
The code we're using is straightforward in this part of the search query: myCriteria.Add(
This is my code so far: The HTML: <form> <label>First Name</label> <input type=text class=first
This happens repeatedly and is very annoying. I upload some PHP code to a
I have some code (it's part of a wordpress plugin) which takes a text

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.