Can anyone give me some advice on the syntax for (var i=0; i<3; i++) document.write("<tr>") document.write("<td colspan=2>") document.write("<table border=0>") document.write("<td width=80 align=left><Font face=Arial size=2 font color=000000><b>BookTitle</b></font></td>") document.write("<td width=180 align=center><Font face=Arial size=2 font color=FF0000><b>Book_Date</b></a></font></td>") document.write("<td width=450><Font face=Arial size=2 font color=3300CC><b> Book_Description</b></a></font></td></table></td></tr>") I can't get it to display the variables I have declared, can anyone help me out with it ? I would like for it to display something like below, formatted and all. Book A Feb AAAAAA Book B Jan BBBBBBB Book C Mar CCCCCC
You need to tell it to print the Javascript variables, such as: document.write("<td width=80 align=left><Font face=Arial size=2 font color=000000><b>" + BookTitle + "</b></font></td>") document.write("<td width=180 align=center><Font face=Arial size=2 font color=FF0000><b>" + Book_Date + "</b></a></font></td>") document.write("<td width=450><Font face=Arial size=2 font color=3300CC><b>" + Book_Description + "</b></a></font></td></table></td></tr>")
Thank you very much vpguy for the help. Would you mind to help me out with this following syntax also ? Thanks a million. document.write("<td width=450><Font face=Arial size=2 font color=3300CC><A href=mailto:info@glebe.edu?subject="+ Book_title, I have read this also +">" + Book_title + "</b></a></font></td></table></td></tr>") I am trying to have the a href automatically generate a subject base on the book title from declared variables. The message subject should read : Book A, I have read this also. once they have click on the href Book title. I keep getting it wrong and it is always displaying ="+ Book_title, I have read this also +" instead of an actual book title.
Any time you are inserting a dynamic variable, you have to stop quoting the literal text and concatenate the contents of the variable. Therefore, the correct version of that piece of code would be: document.write("<td width=450><Font face=Arial size=2 font color=3300CC><A href=\"mailto:info@glebe.edu?subject="+ Book_title + ", I have read this also +"\">" + Book_title + "</b></a></font></td></table></td></tr>") Code (markup): The \" at the beginning and ending of the href encloses it in quotes, because if a space exists it would terminate the href. Instead of \" you could also use a single quote ('). You should also ensure that the Book_title variable contains no quotes, because that would screw up the href.