Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Remember me

Go Back   Tutorialized ForumsWeb Design & DevelopmentJavascript

Add This Thread To:   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
Unread Tutorialized Forums Sponsor:
Old November 28th, 2011, 06:29 PM
carlbrooks carlbrooks is offline
Registered User
Tutorialized Newbie (0 - 499 posts)
Join Date: Nov 2011
Posts: 3 carlbrooks User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 6 m 50 sec
Reputation Power: 0
Table creates new rows when questions are submitted

I have a table which has the number of rows depended on what the number is in the spinner. This does work e.g If I enter 25 in spinner it comes up with 25 rows, if I enter 7 in spinner comes with 7 rows.

So my problem is this:

What I have is a textarea where the user enters in their question and then submits the question, the question should be inserted and appear under the "Question" column.

The problem is that everytime I submit a question into the table, it creates a new row. So if I had 20 empty rows in the table because I stated in the spinner I wanted 20 questions, then what happens is everytime I submit a question, it adds a new row every time, I want the question to be inserted in a current row starting from 1st row add going down 1 row every time a question is submitted.

Below is my javascript code:

function insertQuestion() {   
var table = document.getElementById("qandatbl");
var tableBody = table.tBodies[0];
var textarea = document.getElementById("questionTxt");

var row = document.createElement("tr");

var enumeratorCell = document.createElement("td");
enumeratorCell.className = "qid";

var questionCell = document.createElement("td");
questionCell.className = "question";

var weightCell = document.createElement("td");
weightCell.className = "weight";

var answerCell = document.createElement("td");
answerCell.className = "answer";

var questionText = textarea.value;
var questionContent = document.createTextNode(questionText);


Html code of table and text area with submit button:

// table where questions will be inserted into


    $spinnerCount = $_POST['textQuestion'];
if($spinnerCount > 0) {
   for($i = 1; $i <= $spinnerCount; $i++) {?> // this get the number of questions from the spinner

            <td class="qid"><?php echo $i; ?></td>
            <td class="question"></td>
            <td class="weight"></td>
            <td class="answer"></td>


//Text Area and submit button to submit questions

<form id="enter" action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>" method="post">
<table id='middleDetails' border='1'>
<th class='tblheading' colspan='2'>SESSION DETAILS</th>
<td id="questionNum">Question No </td>
<td id="questionContent">Question:</td> 
<td id="questionTextarea"><textarea rows="5" cols="40" id="questionTxt" name="questionText"></textarea></td>
<td id="addQuestionRow" colspan='2'><input id="addQuestion" type="button" value="Add Question" name="addQuestionBtn" onClick="insertQuestion()" /></td>

Reply With Quote

Viewing: Tutorialized ForumsWeb Design & DevelopmentJavascript > Table creates new rows when questions are submitted

Developer Shed Advertisers and Affiliates

Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 

Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.

© 2003-2019 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap