Jump to content

Recommended Posts

I have a spinner where user enters in their value or uses the buttons to increase or decrease the value. When the user is happy with the value in the spinner the user submits the value. The value would then appears in another table inside a textbox.

 

What my question is, is that how can I get it so that when user submits value in the other table that the spinner buttons are also displayed in the other table so that except the value is in a textbox, it is displayed in a spinner which operates exactly the same as the spinner in the previous table?

 

Below is code where the value from the first spinner is retireved and oututted into another table into a textbox:

 

   function insertQuestion(form) {   
        
    	var row = document.createElement("tr");
    	var cell,
            input,
            alertErrors = "",
            qnum = 1;
    
         cell = document.createElement("td");
         cell.className = "weight";
         input = document.createElement("input");
         input.name = "weight_" + qnum;
         input.onkeypress = "return isNumberKey(event)";
         input.value = form.textWeight.value;
         cell.appendChild(input);
         row.appendChild(cell);
    
    document.getElementById("qandatbl").appendChild(row);
    }

 

Below is html code which shows 3 tables, first table is where the user enters in the value of the answer weight in the spinner, second table is the submit button (Add Question) and third table is where the value is displayed after submission of the first spinner.

 

    <form id="enter" action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>" method="post" onsubmit="return validateForm(this);" >
    <div id="detailsBlock">
    
    <table id="answerWeight">
    <tr>
         <th colspan="3">
         Answer Weight
         </th>
    </tr>
    <tr>
    <td class="spinner">Weight: <input type="text" class="spinnerWeight" name="textWeight" id="txtWeight" />%</td>
    <td><button class="scrollBtn" id="btnWeightUp" type="button"><img src="Images/black_uppointing_triangle.png" alt="Increase" /></button>
    <button class="scrollBtn" id="btnWeightDown" type="button"><img src="Images/black_downpointing_triangle.png" alt="Decrease" /></button></td>
    </tr>
    </table>
    
    <table id="questionBtn" align="center">
    <tr>
    <th>
    <input id="addQuestionBtn" name="addQuestion" type="button" value="Add Question" onClick="insertQuestion(this.form)" />
    </th>
    </tr>
    </table>
    </div>
    
    <hr/>
    <table id="qandatbl" border="1">
    <tr>
        <th class="qid">Question No</th>
        <th class="question">Question</th>
        <th class="option">Option Type</th>
        <th class="answer">Answer</th>
        <th class="weight">Weight</th>
    </tr>
    </table>
    
    </form>

Hoefully that is all the information you require. If you want more information then just add a comment to me. Thank you.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.