Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Array's and Commas

Status
Not open for further replies.

timgerr

IS-IT--Management
Jan 22, 2004
364
US
I have an array that each value of an array holds some html code.
Code:
<html>
  <head>	
	<title>Untitled Document</title>
	<script type="text/javascript">

        	var test = new Array();
		var num;
		test[0] = 'This is a test <br />';
		test[1] = "This is another test <br />";	
	</script>
	</head>
	<body>
		<div id="pHere"></div>
		<script type="text/javascript">
			document.getElementById('pHere').innerHTML = test;
		</script>
		
	</body>
</html>
The problem that I have is the output looks like this
Code:
This is a test
,This is another test
How can (without loops) take out the comma within the output?

thanks,
timgerr

-How important does a person have to be before they are considered assassinated instead of just murdered?
-Need more cow bell!!!

 
Something like:
Code:
document.getElementById('pHere').innerHTML = test.join('');

Lee
 
Here is a summary of what I didn't post, because Lee got there first [smile]

In your code you assign the array to the innerHTML of some node. This is actually the same as using array.join() without passing in a parameter. By passing in a space you are telling it join each item in the array using a space to separate them. You could even pass in an empty string if that was what you wanted!

Hope this helps.

Cheers,
Jeff

[tt]Jeff's Blog [!]@[/!] CodeRambler
[/tt]

Make sure your web page and css validates properly against the doctype you have chosen - before you attempt to debug a problem!

FAQ216-6094
 
Actually, I used an empty string, not a space between the single quotes. A space would produce the same results, though.

Lee
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top