Forum Moderators: open

Message Too Old, No Replies

Commas in URL

URL's in Form Submit.

         

calibrate

3:49 am on Sep 26, 2005 (gmt 0)



On a given form, I submit several URL's much like.

<form method="post" action="save.asp">
<input id="url1" name="url1" />
<input id="url2" name="url2" />
etc.

When I submit the form, I then invoke save.asp....

Here I need to save each URL into a database field. The problem exists where I use the split function to get the form items. If a comma exists, the items are not saved properly. For example:

http://www.example.com,http://www.example2.com < save's ok.
http://www.example.com/0,03882,page.html,http://www.example2.com < does not save ok.

I know the split() function uses the "," character and that I can force the submit to change using javascript.

How do I process a URL that has a "," in it using ASP?

Thanks in advance.

[edited by: Xoc at 12:26 am (utc) on Oct. 27, 2005]
[edit reason] changed to use example.com [/edit]

Scally_Ally

4:26 pm on Sep 29, 2005 (gmt 0)

10+ Year Member



try replacing the commas that occur within the string before you invoke the split function.

URL1 = request.Form("URL1")
URL1 = replace(URL1, "chr(44)", "chr(44)")
URL = split(URL, ",")

whatever........

Then when pulling the information from the database switch them back.

URL1 = replace(URL1, "chr(44)", chr(44))

I know this is a bit crude but it is the way i have always got round " and ' in asp.

If anyone knows a better way then let me know.

Ally

Scally_Ally

4:27 pm on Sep 29, 2005 (gmt 0)

10+ Year Member



sorry, code amend.

second line of code should read

URL1 = replace(URL1, chr(44), "chr(44)")

or you could even use

URL1 = replace(URL1, ",", "chr(44)")

Cheers

cococure

11:57 pm on Sep 30, 2005 (gmt 0)

10+ Year Member



You could also split on: ",http://" and then just add "http://" later to all the items in the array except for the first.

Not elegant, but should work.