Note that there are some explanatory texts on larger screens.

plurals
  1. POChanges to text box are not reflected on webpage
    primarykey
    data
    text
    <p>I need to fill the fields of my webpage when i press the button <code>getDetails</code>. I provide <code>registration id</code> as input, on the basis of which a request to database is made. The response that i receive needs to be displayed on various fields.</p> <p>I am getting the desired response, and processing the response rightly (verified using the google chrome option <code>inspect element</code>). Also i tried to debug the jsp code using Inspect Element, and i found that all the values of response are set correctly, but as the control passes the callback method of the request raised, then my webpage refreshes and URL changes to <code>http://localhost:8080/ReportFetcher/FirstJSP.jsp?regid=2&amp;regIdsubmitbutton=getDetails&amp;Class=0</code></p> <p>whereas i am expecting it to be <code>http://localhost:8080/ReportFetcher/FirstJSP.jsp?</code></p> <p>because this page also has dynamic drop down, in which after selecting one drop down, request is raised, and response is processed and other drop down is populated.</p> <p>This scenario is working fine, so i am unable to figure out why page url change in first case. Also point to note is when put the page under debug in first case i could see the value set in various elements of webpage, that means(in my opinon) values are set first and then page is refreshed, which result in erasing of previously set data.</p> <p>Here is piece of code from jsp file:</p> <pre><code>function funcOnChange(reqElement) { var valueSelected = null; if (reqElement.name == "Class") { valueSelected = reqElement.value; document.detail.regid.disabled = true; } else if (reqElement.name == "regIdsubmitbutton") { valueSelected = "R" + document.detail.regid.value; } document.detail.Section.options.length = 0; if (reqElement.name == "Class" &amp;&amp; valueSelected == "None") { document.detail.Section.disabled = true; return; } var xhr = new XMLHttpRequest(); xhr.onreadystatechange = function() { // Check to see if this state change was "request complete", and // there was no server error (404 Not Found, 500 Server Error, etc) if (xhr.readyState == 4 &amp;&amp; xhr.status == 200) { var substring = xhr.responseText; if (reqElement.name == "regIdsubmitbutton") { parseResponse(substring); } else { document.detail.Section.disabled = false; // loop to update the drop down var pos = doActivateSection(substring); generateTable(substring, pos); } } if (xhr.readyState == 404) { alert("404 error"); } if (xhr.readyState == 500) { alert("500 error"); } } function parseResponse(response) { var name = 0, standard = 1, section = 2, rollno = 3, subject = 4, total_type = 5; var pos; var result = []; var data = []; var type = 0; while (type &lt; total_type) { switch (type) { case name: result = readSegment(response, -1); break; case standard: result = readSegment(response, pos); break; case section: result = readSegment(response, pos); break; case rollno: result = readSegment(response, pos); break; case subject: result = readSegment(response, pos); break; default: break; } data = result[0]; pos = result[1]; type++; updateFormElement((type - 1), data); } } function updateFormElement(type, data) { var element; switch (type) { case 0: element = document.getElementById("studentName"); element.value = data[0]; element.disabled = true; break; case 1: document.detail.Class.options[0] = new Option(data[0], data[0], 0, 0); document.detail.Class.disabled = true; break; case 2: document.detail.Section.options[0] = new Option(data[0], data[0], 0, 0); document.detail.Section.disabled = true; break; case 3: element = document.getElementById("RollNo"); element.value = data[0]; element.disabled = true; break; case 4: break; default: break; } } function readSegment(res, pos) { var value = []; var result = []; var valueindex = 0; for ( var index = pos + 1; index &lt; res.length; index++) { pos = index; if (res[index] == '|') { break; } else if (res[index] == ',') { valueindex++; } else { if (value[valueindex] == null || value[valueindex] == 'undefined') { value[valueindex] = ""; } value[valueindex] = value[valueindex] + res[index]; } } result.push(value); result.push(pos); return result; } &lt;form name="detail" method="post"&gt; &lt;p align="center"&gt;Either Enter :&lt;/p&gt; &lt;span id="01120"&gt;&lt;b&gt;Registration id:&lt;/b&gt;&lt;/span&gt; &lt;input type="text" name="regid"&gt; &lt;span id="01119"&gt;&lt;/span&gt; &lt;input type="submit" value="getDetails" onclick="funcOnChange(this)" name="regIdsubmitbutton"&gt; &lt;br&gt; </code></pre> <p><code>funcOnchange()</code> is called on drop-down's <code>onChange</code> and on <code>onClick</code> of getDetail button. in the <code>parseResponse()</code> response text is parsed and text is set on various textbox. While debugging <code>parseResponse()</code> completes correctly, but after that page refreshes.</p>
    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.
 

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