Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to Refresh Multiple Text areas (with HTML content up to 4000 chars) in HTML-FORM on click of Button in FORM?
    primarykey
    data
    text
    <p>I'm storing Data in PHP Two dimentional Array . Sample Values in PHP ARRAY is mentioned below:</p> <pre><code>First Element in Array ID = 1 QUES= &lt;p&gt;ABCD&lt;/p&gt; OPT_A = &lt;p&gt;A&lt;/p&gt; OPT_B = &lt;p&gt;B&lt;/p&gt; Second Element in Array ID = 2 QUES= &lt;p&gt; TWOABCD &lt;/p&gt; OPT_A = &lt;p&gt;TWA &lt;/p&gt; OPT_B = &lt;p&gt;TWB&lt;/p&gt; </code></pre> <p>I am displaying values of QUEST, OPT_A, OPT_B in TEXTAREA in a HTML FORM (using TinyMCE jquery plugin for displaying rich text). The Form has the following buttons : NEXT &amp; PREVIOUS. </p> <p>On click of NEXT, I want to get TEXT AREAS refeshed with data from next element in array for all values. As per search over internet, I can achieve the same using AJAX, but not sure, how to refresh data of multiple text areas at the same time on click of a button in HTML FORM. Also note data is stored in the form of HTML Tags (with max length upto 4000 chars). </p> <p>Currently, I'm using a very old method, of refreshing entire page on click of button on a form. It's having lot of drawbacks, including when the page gets refreshed, momentarily the user sees HTML tags before the page is loaded completely. </p> <p>Can you please suggest any reference for (fixing these two issues) : </p> <ol> <li>Refreshing Data in Multiple Textares of a HTML-FORM on click of Button (inside HTML-FORM) using AJAX </li> <li>Avoiding momentary display of HTML code in Text area before page is completely loaded.</li> </ol> <p>Updated CODE is mentioned below: </p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;Test&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;form&gt; &lt;input id="id" type="hidden" name="id"&gt; &lt;p&gt;Question:&lt;/p&gt; &lt;p id="myInstance3" style="border: 1px solid #000;"&gt;&lt;textarea id="quest" readonly&gt;&lt;/textarea&gt;&lt;/p&gt; &lt;p&gt;Option A:&lt;/p&gt; &lt;textarea id="opt_a" &gt;&lt;/textarea&gt; &lt;p&gt;Option B:&lt;/p&gt; &lt;textarea id="opt_b" &gt;&lt;/textarea&gt; &lt;p&gt; &lt;button id="previous"&gt;Previous&lt;/button&gt; &lt;button id="next"&gt;Next&lt;/button&gt; &lt;/p&gt; &lt;/form&gt; &lt;script src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; var array = [{"id":1,"quest":"&lt;p&gt;ABC&lt;\/p&gt;","opt_a":"A","opt_b":"B"}, {"id":2,"quest":"&lt;p&gt;DEF&lt;\/p&gt;","opt_a":"1","opt_b":"2"}]; var ArrayWalker = (function () { var _array = null, _index = 0, _walk = function (step) { if (_array === null) { throw 'Array is not initialized'; } _index += step; if (_index &lt; 0 || _index === _array.length) { _index -= step; } return _array[_index]; }; return { init: function (array) { _array = array; _index = 0; }, current: function () { return _walk(0); }, next: function () { return _walk(1); }, previous: function () { return _walk(-1); }, index: function (seek) { if (seek !== undefined) { _index = window.parseInt(seek); } return _index; } }; })(); function fillElements(data) { $('#id').val(data['id']); $('#quest').val(data['quest']); $('#opt_a').val(data['opt_a']); $('#opt_b').val(data['opt_b']); } ArrayWalker.init(array); fillElements(ArrayWalker.current()); $('#previous').click(function (e) { e.preventDefault(); fillElements(ArrayWalker.previous()); }); $('#next').click(function (e) { e.preventDefault(); fillElements(ArrayWalker.next()); }); &lt;/script&gt; &lt;script src="http://js.nicedit.com/nicEdit-latest.js" type="text/javascript"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; bkLib.onDomLoaded(function() { var myNicEditor = new nicEditor(); myNicEditor.setPanel('myNicPanel'); myNicEditor.addInstance('myInstance3'); }); &lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </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.
 

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