*
The moose likes HTML, CSS and JavaScript and the fly likes ++ appears before my table?? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "++ appears before my table??" Watch "++ appears before my table??" New topic
Author

++ appears before my table??

rich werth
Ranch Hand

Joined: Sep 21, 2001
Posts: 57
Hello again..... :-/
I have a strange problem and can't find anything on it no the net or in my books.
I am printing a table using this function...
But when it prints out to either IE or NS I get a ++ before the table. If create the table in the loop I get a ++ before each table. The ++ doesn't appear in the generated source, but only in the output on the screen. What am I doing wrong?
function buildTable() {
var value = document.form1.rowNum.value;
document.write("<table width='95%' border='1' cellspacing='0' cellpadding='0'>"+
"<tr bgcolor='#FFFFCC'><td colspan='14' class='tableHeader'>Detail of Inquiry</td>"+
"</tr>+<tr>+<td colspan='5' bgcolor='#FFFFCC' class='tableHeader'>General Ledger Code</td>"+
"<td width='7%' class='tableHeader' rowspan='2' align='center' bgcolor='#FFFFCC'>Report<br>Date</td></tr></table>")
for (var i = 1; i <= value; i++) {
document.write("<br>Hello")
}
document.close()
}
James Swan
Ranch Hand

Joined: Jun 26, 2001
Posts: 403
Ok, (I'm having some trouble with the UBB code).
change this segment

to

[ April 03, 2002: Message edited by: james swan ]
Randall Twede
Ranch Hand

Joined: Oct 21, 2000
Posts: 4347
    
    2

i tried making a page from your code but it doesnt display anything. im not enough expert to know why. i tried putting it in the body tag but that didnt work either

<html><head></head>
<script language="javascript">
document.write("<table width='95%' border='1' cellspacing='0' cellpadding='0'>"+
"<tr bgcolor='#FFFFCC'><td colspan='14' class='tableHeader'>Detail of Inquiry</td>"+
"</tr><tr><td colspan='5' bgcolor='#FFFFCC' class='tableHeader'>General Ledger Code</td>"+
"<td width='7%' class='tableHeader' rowspan='2' align='center' bgcolor='#FFFFCC'>Report<br>Date</td></tr></table>")
for (var i = 1; i <= value; i++) {
document.write("<br>Hello")
}
document.close()
}
</script>
</html>

i see i missed part of the code i try again
[ April 03, 2002: Message edited by: Randall Twede ]
[ April 03, 2002: Message edited by: Randall Twede ]

SCJP
Visit my download page
Randall Twede
Ranch Hand

Joined: Oct 21, 2000
Posts: 4347
    
    2

arg it still doesnt display anything. i will learn this language yet!

<html><head></head>
<script language="javascript">
function buildTable() {
var value = document.form1.rowNum.value;
document.write("<table width='95%' border='1' cellspacing='0' cellpadding='0'>"+
"<tr bgcolor='#FFFFCC'><td colspan='14' class='tableHeader'>Detail of Inquiry</td>"+
"</tr><tr><td colspan='5' bgcolor='#FFFFCC' class='tableHeader'>General Ledger Code</td>"+
"<td width='7%' class='tableHeader' rowspan='2' align='center' bgcolor='#FFFFCC'>Report<br>Date</td></tr></table>")
for (var i = 1; i <= value; i++) {
document.write("<br>Hello")
}
document.close()
}
window.on load = buildTable;
</script>
</html>

i had to change onload to on load so ubb would accept it. anyway i cant see anything wrong with your code i just wanted to see the effect
[ April 03, 2002: Message edited by: Randall Twede ]
rich werth
Ranch Hand

Joined: Sep 21, 2001
Posts: 57

Correct... that doesn't display anything
there is more to it i didn't think i needed to put it.
If you are trying to use the code i posted put it in between the <head> javaScript in here </head>
in the body of the html i have something like this
<body>
<form name="form1">
<input type="text" name="nameOfTextField">
<input type="button" action="javascript:functionName">
</form>
</body>
just that code it self won't produce anything
and for the ubb code when i'm at work tomorrow i'll cut n paste it again correctly sorry....
and that html code up there isn't 100% right i just whipped it up to give a general idea.
James Swan
Ranch Hand

Joined: Jun 26, 2001
Posts: 403
Ok,
the reason why ++ would appear on your page is because it got included in the literal HTML that you were generating:
- Strings are delimited by ""
- + can be used to concatenate Strings
- some of your +'s were included in the Strings and are being treated as literals as opposed to contentation operators.
I tried to explain that in my post above, but didn't do such a good job.
Randall Twede
Ranch Hand

Joined: Oct 21, 2000
Posts: 4347
    
    2

james,
d'oh. now i see what the problem was i thought rich had posted your first post and was just clarifying...i should pay more attention

rich, james is absolutely correct. his code change should fix your problem
[ April 03, 2002: Message edited by: Randall Twede ]
James Swan
Ranch Hand

Joined: Jun 26, 2001
Posts: 403
Randall, Rich,
sorry for the confusion, I was originally trying to highlight the part of Rich's code that had the issue, with the UBB bold tag, but it wasn't working out for me.
So after 3 attempts the above post was the outcome (it made sense in my mind ).
Randall Twede
Ranch Hand

Joined: Oct 21, 2000
Posts: 4347
    
    2

james, no need for apologies you solved his problem
im not real fond of UBB myself. i find it very iritating to have to modify the code for events when html is supposed to be disabled. it has even been mentioned in the moderators only forum that this is a pain.
[ April 03, 2002: Message edited by: Randall Twede ]
[ April 03, 2002: Message edited by: Randall Twede ]
Randall Twede
Ranch Hand

Joined: Oct 21, 2000
Posts: 4347
    
    2

in fact i think something must be done about it. at least some message in this forum saying you dont have to change all your <'s and >'s but only have to change the event code. i am gonna go start a thread about it.
Randall Twede
Ranch Hand

Joined: Oct 21, 2000
Posts: 4347
    
    2

it's done, hopefully soon there will be bold red text explaing about the shortcoming of UBB and what to do. i hate to imagine someone tediously changing all their <'s and >'s because thats what UBB recommends
Randall Twede
Ranch Hand

Joined: Oct 21, 2000
Posts: 4347
    
    2

no responses yet in moderators only but it is now night for most of them...ill keep you informed if there are any beneficial changes. i definatetly want some bold red near the top that briefly explains the prob and what to do about it.
im just asking for help for this one problem, if anyone doesnt understand the UBB codes, click the link to your left. it explains it.
Randall Twede
Ranch Hand

Joined: Oct 21, 2000
Posts: 4347
    
    2

arg.. its not always there on my left
http://www.javaranch.com/cgi-bin/ubb/ultimatebb.cgi?ubb=ubb_code_page
rich werth
Ranch Hand

Joined: Sep 21, 2001
Posts: 57
Hi Randall and James
Thanks for replying.
You were right with the pluses. I didn't see them in there.
Thanks for helping!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: ++ appears before my table??