PDA

View Full Version : Big problem with dynamic table


Anarchist
03-27-2005, 10:15 PM
I have been working for ages trying to get a similar version of this table Click (http://homepage.ntlworld.com/charlie_chuck/calcpop.html) to work.

This version in the link has the form and elements in the html page whereas the version I am trying to get running has the form and form elements produced by my script dynamically.

This version does work up to a point, but the calculations are way off mark and appear in the wrong text box.

I think my problem lies in the loop which calls the array data but I cannot track it down.

Harry Armadillo
03-28-2005, 01:17 AM
Second link is broken.

First, you're going to have an easier time debugging if you test with less toys. Next, read through what you are document.write-ing (by changing < in the tags to &lt; ).

Eliminate the extra </th> and get your </tr>'s in the right place, then work on the functions (what is document.getElementById(total) supposed to reference...).

Anarchist
03-28-2005, 09:48 AM
document.getElementById(total) supposed to reference...).

This is a part of the working code in my script, that works perfectly in my other table. Second link is fixed

Garadon
03-28-2005, 11:01 AM
document.write("<td align='center'>");
document.write('<input type="text" input id="txtQuantity'+j+'" name="txtQuantity'+j+'" size=20 value="####">');
document.write("</td>");
document.write("<td align='center'>");
document.write('<input type="text" id="txtTotal'+j+'" name="txtTotal'+j+'" size=20 disabled="disabled" value="0">');
document.write("</td>");
document.write("</tr>");
document.write("<td align ='center'>");
document.write('<input type="hidden" name="hdnprice'+j+'" id="hdnPrice'+j+'" size="20" value="'+toys[j][2]+'">');
document.write("</td>")

}
document.write("<tr>");
document.write("<td>");
document.write("Testing");
document.write("</td>");
document.write("<td>");
document.write('<input name="txtSubtotal" id="txtSubTotal" type="text" value="0" disabled="disabled">');

Anarchist
03-28-2005, 11:09 AM
Could you explain to me what I did wrong? So I know for next time please.

EDIT Oh no, so simple the quotation marks right? :thumbsup:

Garadon
03-28-2005, 12:59 PM
yes and then some case stuff and some slashes, and some other quite funny things :).

I suggest next time you use Id only in your script. :P

Anarchist
03-28-2005, 01:53 PM
Believe it or not ;) if you only change the quotation marks the other errors don't interfere.

The script works. :)

Are you up to help me somemore?

I have created a function to convert the totals to currency but I am not able to use it.

This is the first time I have used this method of dynamic forms or tables and I am not sure where to place the code.

The function is fine though.