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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T17:15:51+00:00 2026-05-28T17:15:51+00:00

I have a table where the user can add rows to it but each

  • 0

I have a table where the user can add rows to it but each row is numbered. Now the user enters a number in a textbox for the number of rows he/she wants to add before they actually start adding rows. Below is the code where if the number of rows that has been added is over the number entered by the user, then it stops adding the rows.

    if (qnum > <?php echo (int)@$_POST['textQuestion']; ?>) {
    return;
}

Example: if user entered in the number 5 in a textbox, then the user can only add 5 rows, if the user tries to add another row, then no row is added because user can’t add more than 5 rows.

What my question is that if the user has already reach the max number of rows they have added, then I want it to disable a textarea (user wont be able to click in the textarea and I want to give it the correct colour so that you can tell the textarea is disabled). I also want to disable a hyperlink so that user cannot click on the hyperlink (again suitable color change so user can tell hyperlink is disabled) Does anyone know how to do this?

Below is code for hyperling and the textarea:

    <table id="question">
    <tr>
        <th colspan="2">
            Question Number <span id="questionNum">1</span>
        </th>
    </tr>
    <tr>
        <td rowspan="3">Question:</td> 
        <td rowspan="3">
            <textarea id="questionTextArea" rows="5" cols="40" name="questionText"></textarea>
<span href="#" class="link">[Question link]</span>
        </td>
    </tr>
    </table>

Jquery code showing example of how a table row is added:

function insertQuestion(form) {   

      var questionarea=(form.questionText.length)
                ? form.questionText[0]
                : form.questionText;

            var context = $('#optionAndAnswer');
    var currenttotal = context.find('.answerBtnsOn').length;        

        alertErrors = "";
        // Note, this is just so it's declared...


    if (questionarea.value == ""){

    if (qnum > <?php echo (int)@$_POST['textQuestion']; ?>) {
    return;
}

    var $tbody = $('#qandatbl > tbody'); 
    var $tr = $("<tr class='optionAndAnswer' align='center'></tr>");
    var $qid = $("<td class='qid'>" + qnum + "</td>");

$tr.append($qid);
 $tbody.append($tr);    

}

Html table where the table row is added to:

<table id="qandatbl" align="center">
<thead>
<tr>
    <th class="qid">Question No</th>
</tr>
</thead>
<tbody></tbody>
</table>

look at this jsfiddle for example here, you can write a question on top using the textarea and when you have done that then click on the button to add it in a new row. It is the top textarea I want to disable only if the number of rows has met its limit.

  • 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-28T17:15:52+00:00Added an answer on May 28, 2026 at 5:15 pm

    Are you adding rows via JavaScript/Ajax or on page load?

    If the former (which I’m guessing your first code example illustrates), use a JavaScript counter to represent the number of rows, and when they trigger the add row function (which you write), check that number first; alert and disabled accordingly:

    jQuery allows you to disable form elements, and just replace the link with the link text (ie. minus the tag), and modify it’s color, either with a $(ele).css() call, or by wrapping it in a span tag.

    If the latter, you can just write the textarea via PHP with the disabled=”disabled” property added to the opening tag. The link: use the same method as above (wrapping it in a span tag, rather than an a tag).


    // To disable
    $('.someElement').attr('disabled', 'disabled');
    
    // To enable
    $('.someElement').removeAttr('disabled');
    

    Obviously, you need to include the jQuery framework. I usually use Google’s: https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js.

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

Sidebar

Related Questions

I have a table of data sorted by date, from which a user can
I have a table User which has an identity column UserID , now what
I have a table with user items. Each user may have several types of
I have an update panel which contains a table, to which I add rows
I have a WPF DataGrid with some data. You can add rows through a
Take tables: User, Comment, Snippet. A User can have many Snippets. A Snippet can
I have a tabled view in a while loop, where a user can view
I have a table (user) that contains user information. I have another table (userview)
I have a table like so: Table eventlog user | user_group | event_date |
I'm just learning ruby on rails and I have a table of user roles

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.