473,395 Members | 2,798 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Help - Space in script that splits string at comma

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[i] + "'>" + input[i] + "</a>" +"<br>";
} document.all("dev").innerHTML = input2;
}
</script>



Jul 23 '05 #1
1 1196
Hoggman wrote:
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[i] + "'>" + input[i] + "</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

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq
Jul 23 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Joseph | last post by:
I have a textBox that people writes stories in it. They can use for format. I have Aspell installed on the server, so people can make correction to their text. Sometimes, they forget to add a...
8
by: baustin75 | last post by:
Posted: Mon Oct 03, 2005 1:41 pm Post subject: cannot mail() in ie only when debugging in php designer 2005 -------------------------------------------------------------------------------- ...
2
by: Trint Smith | last post by:
Ok, My program has been formating .txt files for input into sql server and ran into a problem...the .txt is an export from an accounting package and is only supposed to contain comas (,) between...
18
by: yawnmoth | last post by:
Say I have the following script: <? $string = 'test'; if (eregi("^+$",$string)) { echo 'matches!'; } else {
2
by: karups | last post by:
Hi, I've got listbox in my .aspx page where the users can make multiple selection. So, Users can select any number of items in listbox, I have to take value from items and pass it to stored...
13
by: James | last post by:
Is this possible? I want to pass an array into a function that contains txtBox.Text properties... I was thinking something like this, but I know it won't work Dim vendorFields(9) As String ...
2
by: varusnyc | last post by:
Hello, I just started learning strings and dont even know how to properly execute simple part of the program that splits phrase of two words with one space in between into 2 separate strings. I...
9
by: pic078 via AccessMonster.com | last post by:
I need serious help - I have a frontend/backend Access database (2 MDE Files) that remains stuck in task manager after exiting the application - you can't reopen database after exiting as a result...
4
by: =?Utf-8?B?bWFnZ2ll?= | last post by:
hi, I need some help with a reg. expression. I have a comma delimited file with quotes. Not every field has quotes, only some. This is a sample of my file:...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.