473,769 Members | 1,640 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Replace commas in values in an array

Although this is a client side issue, I am also posting to asp.general
in case there is someway to do this only server side (which I would
prefer).

Here's my form:

<form method="post" action="<%=requ est.servervaria bles("Script_na me")
%>"
<% for i - 0 to 4%>
Header: <input type="text" name="header" id="header<%=i% >"
onblur="functio n(this)"><br>
Description: <input type="text" name="descripti on" id="description <%=i
%>" onblur="functio n(this)">
<% next%>
<input type="submit" value="Submit">
</form>

When the data gets returned it's something like:
header: "socks, shoes, pizza, cats, dogs"
description: "good for feet, wear with socks, cheese only, have lots
of hair, bark a lot"

Problem comes when the description or header have a comma. I need a
little javascript that will replace the comma with a semicolon client
side before it gets to
the server, preferably as they leave the field.

Any help with this would be much appreciated.

--
Adrienne Boswell at work
Administrator nextBlock.com
http://atlas.nextblock.com/files/
Please respond to the group so others can share

Apr 5 '07 #1
14 7092
Adrienne Boswell wrote on 06 apr 2007 in
microsoft.publi c.inetserver.as p.general:
Although this is a client side issue, I am also posting to asp.general
in case there is someway to do this only server side (which I would
prefer).
[...]
Problem comes when the description or header have a comma. I need a
little javascript that will replace the comma with a semicolon client
side before it gets to the server, preferably as they leave the field.
I doubt you can do anything serverside before it gets to the server,
Adrienne.

Clientside it is simple, just do a regex global replace.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Apr 5 '07 #2
Adrienne Boswell wrote:
Problem comes when the description or header have a comma. I need
a little javascript that will replace the comma with a semicolon
client side before it gets to the server, preferably as they leave
the field.
Assuming from your example that you want the expression for your onblur
handler, here is one way:

onblur="this.va lue=this.value. split(',').join (';')"

Another:

onblur="this.va lue=this.value. replace(/,/g,';')"

--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms.
Apr 5 '07 #3

Dave Anderson wote:
Adrienne Boswell wrote:
Problem comes when the description or header have a comma. I need
a little javascript that will replace the comma with a semicolon
client side before it gets to the server, preferably as they leave
the field.

Assuming from your example that you want the expression for your onblur
handler, here is one way:

onblur="this.va lue=this.value. split(',').join (';')"

Another:

onblur="this.va lue=this.value. replace(/,/g,';')"
Dave, you're an officer, a genteman and a fine judge of women! Thanks
so much - works perfectly!

--
Adrienne Boswell at work
Administrator nextBlock.com
http://atlas.nextblock.com/files/
Please respond to the group so others can share

Apr 5 '07 #4
On Apr 6, 8:02 am, "Adrienne Boswell" <arb...@yahoo.c omwrote:
Although this is a client side issue,
It is a server issue.

I am also posting to asp.general
in case there is someway to do this only server side (which I would
prefer).

Here's my form:

<form method="post" action="<%=requ est.servervaria bles("Script_na me")
%>"
<% for i - 0 to 4%>
Header: <input type="text" name="header" id="header<%=i% >"
onblur="functio n(this)"><br>
Description: <input type="text" name="descripti on" id="description <%=i
%>" onblur="functio n(this)">
<% next%>
<input type="submit" value="Submit">
</form>
Don't post server code to a group concerned with client scripting,
post whatever it is that the client gets. However you generate that
is up to you.

When the data gets returned it's something like:
header: "socks, shoes, pizza, cats, dogs"
description: "good for feet, wear with socks, cheese only, have lots
of hair, bark a lot"
Tell your users not to use commas and use normal validation
techniques.

Problem comes when the description or header have a comma. I need a
little javascript that will replace the comma with a semicolon client
side before it gets to
the server, preferably as they leave the field.
Client scripting is unreliable, deal with it at the server.

For luck, you can use something like:

<input onblur="this.va lue=this.value. replace(/,/g,';');" ... >
though you are better to do the replace onsubmit when you do the rest
of your client-side validation, users will likely get confused seeing
their commas turn into semi-colons after they leave the field. And if
scripting is disabled, not available or fails, you will still get
commas in the data.
--
Rob

Apr 6 '07 #5
"Adrienne Boswell" wrote:
Dave, you're an officer, a genteman and a fine judge of women!
Thanks so much - works perfectly!
I am glad to hear it. However...

....I feel I should echo RobG here in warning that security (and this
includes data integrity) really does belong on the server. So, if you are
inclined to agree, perhaps you would consider using this approach over on
the server side.

JScript ASP example:
(Request.Form(" description").I tem || "").replace (/,/g,";")
VBScript candidate:
Join(Split(Requ est.Form("descr iption") & "",","),";" )

--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms.

Apr 6 '07 #6
On Apr 5, 6:02 pm, "Adrienne Boswell" <arb...@yahoo.c omwrote:
Although this is a client side issue, I am also posting to asp.general
in case there is someway to do this only server side (which I would
prefer).

Here's my form:

<form method="post" action="<%=requ est.servervaria bles("Script_na me")
%>"
<% for i - 0 to 4%>
Header: <input type="text" name="header" id="header<%=i% >"
onblur="functio n(this)"><br>
Description: <input type="text" name="descripti on" id="description <%=i
%>" onblur="functio n(this)">
<% next%>
<input type="submit" value="Submit">
</form>

When the data gets returned it's something like:
header: "socks, shoes, pizza, cats, dogs"
description: "good for feet, wear with socks, cheese only, have lots
of hair, bark a lot"

Problem comes when the description or header have a comma. I need a
little javascript that will replace the comma with a semicolon client
side before it gets to
the server, preferably as they leave the field.

Any help with this would be much appreciated.

--
Adrienne Boswell at work
Administrator nextBlock.com
http://atlas.nextblock.com/files/
Please respond to the group so others can share
you could do it in javascript using regular expression. i believe
something like this would work:

var someStringVaria ble = "asdfasd asdf asdfa, asdfasdf asdksdas,
asdfas";
someStringVaria ble = someStringVaria ble.replace(/,/, ";");

i'd probably go about it a different way, though. i'd give each
<inputtag a unique name, so you dont have to worry about the values
being squashing into one value.

Apr 6 '07 #7
br************@ gmail.com wrote:
you could do it in javascript using regular expression. i believe
something like this would work:

var someStringVaria ble = "asdfasd asdf asdfa, asdfasdf asdksdas,
asdfas";
someStringVaria ble = someStringVaria ble.replace(/,/, ";");
Don't just believe it, try it. Then you will notice that you need a global
flag.

--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms.
Apr 6 '07 #8
Gazing into my crystal ball I observed "Dave Anderson"
<NY**********@s pammotel.comwri ting in
news:13******** *****@corp.supe rnews.com:
"Adrienne Boswell" wrote:
>Dave, you're an officer, a genteman and a fine judge of women!
Thanks so much - works perfectly!

I am glad to hear it. However...

...I feel I should echo RobG here in warning that security (and this
includes data integrity) really does belong on the server. So, if you
are inclined to agree, perhaps you would consider using this approach
over on the server side.

JScript ASP example:
(Request.Form(" description").I tem || "").replace (/,/g,";")
VBScript candidate:
Join(Split(Requ est.Form("descr iption") & "",","),";" )
I don't think that's going to work, here's why:

Let's say that request.form("n umbers") = "1, 2, 3, 4" and request.form
("descriptio n") = "eggs, bacon, milk, butter"
numbersarr = split(request.f orm("numbers"))
descarr = split(request.f orm("descriptio n"),",")
for i = 0 to ubound(numbersa rr)
response.write numbersarr(i) & "=" & descarr(i)
next

That works if the arrays are both the same size. If request.form
("descriptio n") = "eggs, milk, butter, sugar, flour" then you've got a
problem.

The form I am making has 10 rows of 5 items each, so that's why I'm doing
it client side.

--
Adrienne Boswell at Home
Arbpen Web Site Design Services
http://www.cavalcade-of-coding.info
Please respond to the group so others can share

Apr 6 '07 #9
Adrienne Boswell wrote on 06 apr 2007 in
microsoft.publi c.inetserver.as p.general:

I don't think that's going to work, here's why:

Let's say that request.form("n umbers") = "1, 2, 3, 4" and request.form
("descriptio n") = "eggs, bacon, milk, butter"
numbersarr = split(request.f orm("numbers"))
numbersarr = split(request.f orm("numbers"), ",")
descarr = split(request.f orm("descriptio n"),",")
if ubound(numbersa rr)>=ubound(des carr) then
max = ubound(descarr)
else
max = ubound(numbersa rr)
end if
for i = 0 to max - 1
....
for i = 0 to ubound(numbersa rr)
response.write numbersarr(i) & "=" & descarr(i)
next

That works if the arrays are both the same size. If request.form
("descriptio n") = "eggs, milk, butter, sugar, flour" then you've got a
problem.
See serverside solution above.
The form I am making has 10 rows of 5 items each, so that's why I'm
doing it client side.
??

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Apr 6 '07 #10

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

Similar topics

14
2302
by: Mike N. | last post by:
Hello: I have a form that contains a multiple-select field that has 12 options in it. I would like the user to be able to select UP TO FOUR of those options. If they select more than four, I would like to alert them of the error. To do this, I figure that counting commas would be the easiest method (i.e., IF commas > 3 THEN alert user). NOTE: I have an existing "validateForm" function for this form and I'd like to add this IF-THEN...
22
13774
by: ineedyourluvin1 | last post by:
Hello all! I've been looking for a way to strip characters from strings such as a comma. This would be great for using a comma as a delimiter. I show you what I have right now. #include<iostream> #include<string> int main(int argc, char *argv) {
4
2194
by: serge | last post by:
I managed to put together C# code and have it do the following: 1- Get all the table names that start with the letter "Z" from sysobjects of my SQL 2000 database and put these table names inside an array variable. 2- Loop through each table name inside the array 1 to 1000 tables
4
1466
by: Tony WONG | last post by:
i have an array data, like this 1234,4565,7890,3478 i use replace to replace "," to ";" for fitting into the data input however, i choose record according to the "selected" checkbox, then the text like this 1234,,,3478
3
3004
by: Roy W. Andersen | last post by:
Hi, I need to do some replace-calls on certain strings in order to replace smiley glyphs and other keywords with graphical icons on the client. Unfortunately, my knowledge of regular expressions is somewhat limited to say the least, so I'm struggling with making it work as I wand. What I have is an associative array like this: smileys = 'smile.gif'; smileys = 'sad.gif';
11
10494
by: Dooza | last post by:
Using ASP/VB I need to remove unwanted commas from the end of a field that will be use in an array. There are items in the field that are comma separated, so I don't want to remove them, just the end ones, could be anywhere up to 5 unwanted commas. Any ideas? Cheers, Steve
11
1920
by: James Kanze | last post by:
On Apr 11, 6:48 am, Jerry Coffin <jerry.cof...@gmail.comwrote: The combination of the two. *IF* it is appropriate to use a container here, that container
7
1268
by: | last post by:
Hello guys! I am trying to make something here,,, i am not an experienced php user so this might be an easy question but for me it seems like a mountain! So, i got a field in mySQL in which data is stored in this way: 3,55,85,77,63,1,2,...,...,... which means, numbers seperated by commas. I need, when reading this field to get each number in a seperate variable or array... Can you help me out?
0
9423
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10211
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10045
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8870
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6673
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5298
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5447
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3958
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.