Help - Space in script that splits string at comma

H

Hoggman

Hi all

take a look at http://www.beal-homes.com/test.asp

I have used the script below to split a field down at commas and then
created a new string

This works but after the first item there is a space where the comma used to
be, is there any way I can remove this?

Thanks

Matt Houldsworth



<script language="javascript">
var devText="<%=(houses.Fields.Item("location").Value)%>";

function getDevelopments() {
var input = devText.split(",");
var input2 = new String();
for (var i = 0; i<input.length; i++) {
input2 += "<a
href='home_template.asp?id=<%=(houses.Fields.Item('id').Value)%>&titleofdeve
lopment=" + input + "'>" + input + "</a>" +"<br>";
} document.all("dev").innerHTML = input2;
}
</script>
 
R

Randy Webb

Hoggman said:
Hi all

take a look at http://www.beal-homes.com/test.asp

I have used the script below to split a field down at commas and then
created a new string

This works but after the first item there is a space where the comma used to
be, is there any way I can remove this?

Thanks

Matt Houldsworth



<script language="javascript">
var devText="<%=(houses.Fields.Item("location").Value)%>";

The output of that server side code is this:
var devText="Leaf Sail Farm, Church View, The Willows";

That is where your spaces are coming from.

To remove them, either remove them on the server or check the FAQ of
this group for the Trim, LTrim and RTrim functions.
function getDevelopments() {
var input = devText.split(",");
var input2 = new String();
for (var i = 0; i<input.length; i++) {
input2 += "<a
href='home_template.asp?id=<%=(houses.Fields.Item('id').Value)%>&titleofdeve
lopment=" + input + "'>" + input + "</a>" +"<br>";
} document.all("dev").innerHTML = input2;


document.all is not a function.

thats the error message Mozilla gives.

While reading the FAQ, check on DynWrite
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top