Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I'm not really too sure if I understand your question completely, but I tried out your application a few times and I think I understand: Load a result from the database -> populate fields with the result ?</p> <p>Anyway, I see you're using Jquery, so I think you should be able to use .html() or .append() to add each button in a for loop: (I assume you've stored your answer buttons in an array). I'm lazy so I usually name targets with an ID #ButtonHolder is your for the buttons. </p> <pre><code>var buttonhtml = ""; //I personally like to build the html then insert it. var lastchar = gridValues.charCodeAt(gridvalues.length-1); for (i=65;i&lt;=lastchar;i++) // 65 is the code for "A" buttonhtml += "&lt;input type=\"button\" onclick=\"btnclick(this);\" value=\""+String.fromCharCode(i)+"\" id=\"answer"+String.fromCharCode(i)+"\" name=\"answer"+String.fromCharCode(i)+"Name\" class=\"answerBtns answers answerBtnsOn\"&gt;"; $("#ButtonHolder").html(buttonhtml); </code></pre> <p>Have you thought about instead of using onclick, using JQuery to handle the clicks with a class?</p> <p>Edit:</p> <pre><code>function addwindow(questionText,textWeight,numberAnswer,gridValues) { if(window.console) console.log(); if($(plusbutton_clicked).attr('id')=='mainPlusbutton') { if( gridValues != "True or False" &amp;&amp; gridValues != "Yes or No" ) { var myNumbers = {}; myNumbers["A-C"] = "3"; myNumbers["A-D"] = "4"; myNumbers["A-E"] = "5"; //... myNumbers["A-Z"] = "26"; gridValues = myNumbers[gridValues]; $('#mainNumberAnswerTxt').show(); } else{ $('#mainNumberAnswerTxt').hide(); } $('#mainTextarea').val(questionText); $('#mainTxtWeight').val(textWeight); $('#mainNumberAnswerTxt').val(numberAnswer); $('#mainGridTxt').val(gridValues); } else { $(plusbutton_clicked).closest('tr').find('input.numberAnswerTxtRow').val(numberAnswer); $(plusbutton_clicked).closest('tr').find('input.gridTxtRow').val(gridValues); var lastchar = gridValues.charCodeAt(gridValues.length-1); // getting the last charcode i.e. "A-D" -&gt; "D" -&gt; 68 $(".ansBtns").removeClass("answerBtnsOn").addClass("answerBtnsOff"); // reset all the buttons to off *I think this works* // 65 is the code for "A" Iterating each choice and activating it: for (i=65;i&lt;=lastchar;i++) $("#answer"+String.charCodeAt(i)).addClass("answerBtnsOn"); $.modal.close(); return false; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload