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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T06:50:36+00:00 2026-06-01T06:50:36+00:00

Below is my javascript and form code where it appends a question number (qnum)

  • 0

Below is my javascript and form code where it appends a question number (qnum) for each table row appended in the application one by one. So if user adds a table row then it contains question number 1, when second row is added, question number 2 is added, then 3 for third row and etc.

<script>

    function insertQuestion(form) {   

        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); 

        ++qnum;
        $("#questionNum").text(qnum);

</script>


<form id="QandA" action="insertQuestion.php" method="post" >

<div id="detailsBlock">
    <table id="question">
        <tr>
            <th colspan="2">
                Question Number <span id="questionNum">1</span>
            </th>
        </tr>
    </table>
</form> 

The problem I have is that I want to do a $_POST in the next page for all the question numbers added. The only problem is that because I am not using an input field, I do not have a name attribute to $_POST. so what I want to know is that if I can use ‘name’ attribute to $_POST, then how else can I post the question numbers?

  • 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-01T06:50:37+00:00Added an answer on June 1, 2026 at 6:50 am

    You can do something like this. Add a hidden field to your markup. Hidden variables are posted back to the server and are available in $_POST with their name. I have added the 2 lines starting with ** and ending with **

    <script>
    
        function insertQuestion(form) {   
    
            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); 
    
            ++qnum;
            $("#questionNum").text(qnum);
            **$("#num_questions").val(qnum);**
    
    </script>
    
    
    <form id="QandA" action="insertQuestion.php" method="post" >
    **<input type="hidden" id ="num_questions" value="" name="num_questions">**
    <div id="detailsBlock">
        <table id="question">
            <tr>
                <th colspan="2">
                    Question Number <span id="questionNum">1</span>
                </th>
            </tr>
        </table>
    </form> 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a form below and some javascript code in php, the it
Hello I have a question with javascript form validation and regular expressions. Below is
How would I achieve the pseudo-code below in JavaScript? I want to include the
HI all, Below mentioned javascript code works fine in all browsers including chrome(from second
refer my below javascript code , how to count rows if i click add
Below is my javascript code snippet. Its not running as expected, please help me
I have a php form which allows the user to provide a reference number
The below class inherits from the Textarea widget and features javascript code that displays
why the below javascript code always returns null (mean alert) ? <%@ Page Language=C#
I have the following Javascript code: function checkIfValid(){ var form = document.createuserform; if(form.fName.value ==

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.