Note that there are some explanatory texts on larger screens.

plurals
  1. POAppending the results of a load() into a table with JQuery and formatting it
    primarykey
    data
    text
    <p>I am trying to append data from a JQuery load() into a table.While i am able to append the data into the table successfully, the appended results are not formatted in line with the rest of the table.</p> <p><strong>Current Format of table(after appending)</strong></p> <pre><code>+---------------------------------------------------+ | Data | ----------------------------------------------------- | Data | Data | ----------------------------------------------------- | Data | Data | ----------------------------------------------------- |Append data|Append data | -------------------------- |Append data|Append data | -------------------------- |Append data|Append data | -------------------------- |Append data|Append data | -------------------------- </code></pre> <p><strong>Desired Format</strong></p> <pre><code>+---------------------------------------------------+ | Data | ----------------------------------------------------- | Data | Data | ----------------------------------------------------- | Data | Data | ----------------------------------------------------- | Append Data | Append Data | ----------------------------------------------------- | Append Data | Append Data | ----------------------------------------------------- | Append Data | Append Data | ----------------------------------------------------- </code></pre> <p><strong>Extract of code:</strong></p> <pre><code> &lt;table id="edititemtable" border='1'&gt; &lt;tr&gt; &lt;td colspan='2'&gt;Item Info&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Select Category: &lt;/td&gt; &lt;td&gt; &lt;select id='changeitemcat' name='changeitemcat'&gt;&lt;/select&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Select SubCategory: &lt;/td&gt; &lt;td&gt; &lt;select id='changeitemsubcat' name='changeitemsubcat'&gt;&lt;/select&gt; &lt;/td&gt; &lt;/tr&gt; &lt;div id="details" name="details"&gt; &lt;/div&gt; &lt;/table&gt; </code></pre> <p><strong>Extract of JQuery Used</strong></p> <pre><code>$("#edititemtable").append($("#details").load('changeitem.php?cat='+cat+'&amp;subcat='+subcat+'&amp;item='+item)); </code></pre> <p>Extract of .load() file</p> <pre><code>while($extractdetails=$getitem-&gt;fetch(PDO::FETCH_ASSOC)) { //Data is saved into the associated variables echo"&lt;tr&gt;"; echo"&lt;td&gt;"; echo"Item Name"; echo"&lt;/td&gt;"; echo"&lt;td&gt;"; echo"&lt;input type='text' id='changeitemname' name='changeitemname' value=$itemname size='30' maxlength='50' /&gt;"; echo"&lt;/td&gt;"; echo"&lt;/tr&gt;"; echo"&lt;tr&gt;"; echo"&lt;td&gt;"; echo"Item Price"; echo"&lt;/td&gt;"; echo"&lt;td&gt;"; echo"&lt;input type='text' id='changeitemprice' name='changeitemprice' value=$itemprice size='7' maxlength='7' /&gt;"; echo"&lt;/td&gt;"; echo"&lt;/tr&gt;"; echo"&lt;tr&gt;"; echo"&lt;td&gt;"; echo"Item Info"; echo"&lt;/td&gt;"; echo"&lt;td&gt;"; echo"&lt;textarea class='textarea' id='changeiteminfo' name='changeiteminfo' col='10' rows='10' maxlength='300' &gt;$iteminfo&lt;/textarea&gt;"; echo"&lt;/td&gt;"; echo"&lt;/tr&gt;"; echo"&lt;tr&gt;"; echo"&lt;td&gt;"; echo'&lt;form id="changeitem" name="changeitem" method="POST" action=""&gt;'; echo"&lt;input type='hidden' id='changeitemid' name='changeitemid' value='$itemid' /&gt;"; echo"&lt;input type='submit' id='changeitemsubmit' name='changeitemsubmit' value='Save Changes' /&gt;"; echo"&lt;/form&gt;"; echo"&lt;/td&gt;"; echo"&lt;/tr&gt;"; </code></pre> <p>}</p> <p><strong>QUESTION</strong></p> <p>How do i get the desired format?</p> <p>Why is the appended data being forced into one of the ?</p> <p><strong>SOLUTION:</strong></p> <pre><code>&lt;table id="edititemtable" border='1'&gt; &lt;tr&gt; &lt;td colspan='2'&gt;Item Info&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Select Category: &lt;/td&gt; &lt;td&gt; &lt;select id='changeitemcat' name='changeitemcat'&gt;&lt;/select&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Select SubCategory: &lt;/td&gt; &lt;td&gt; &lt;select id='changeitemsubcat' name='changeitemsubcat'&gt;&lt;/select&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td colspan="2" id="details" name="details"&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; </code></pre> <p>P.s I'm currently using HTML 5 and PHP</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