Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > putting '/' in field name

Reply
Thread Tools

putting '/' in field name

 
 
Stuart Palmer
Guest
Posts: n/a
 
      10-30-2003
Hi everyone,
I have a form with '/' in some of the field names, when I pass through to
the next page the field name comes back as though it's been htmlencoded, so
getting the value out of the field I need to convert this back to '/' with
the replace (same problem if I have a ',' in the name)

Is there an easy way to htmldecode or something what it converted to the
encoded versions? (I have written a short function to basically do all my
replaces for me, but I am guessing this isn't the ideal solution)

Many thanks

Stu



 
Reply With Quote
 
 
 
 
Chris Barber
Guest
Posts: n/a
 
      10-30-2003
Not being argumentative but why would you ever want to have a form field
name with a '/' in it - it's such a patently horrible thing to have to deal
with.
My suggestion: change the field names.

Chris.

"Stuart Palmer" <(E-Mail Removed)> wrote in message
news:bnqpfq$ug0$(E-Mail Removed)...
Hi everyone,
I have a form with '/' in some of the field names, when I pass through to
the next page the field name comes back as though it's been htmlencoded, so
getting the value out of the field I need to convert this back to '/' with
the replace (same problem if I have a ',' in the name)

Is there an easy way to htmldecode or something what it converted to the
encoded versions? (I have written a short function to basically do all my
replaces for me, but I am guessing this isn't the ideal solution)

Many thanks

Stu




 
Reply With Quote
 
 
 
 
Jeff Cochran
Guest
Posts: n/a
 
      10-30-2003
On Thu, 30 Oct 2003 10:42:30 -0000, "Stuart Palmer"
<(E-Mail Removed)> wrote:

>Hi everyone,
>I have a form with '/' in some of the field names, when I pass through to
>the next page the field name comes back as though it's been htmlencoded, so
>getting the value out of the field I need to convert this back to '/' with
>the replace (same problem if I have a ',' in the name)
>
>Is there an easy way to htmldecode or something what it converted to the
>encoded versions? (I have written a short function to basically do all my
>replaces for me, but I am guessing this isn't the ideal solution)


Better than a replace is simply not to name fields with any characters
other than alphanumeric. Including no spaces. Most languages have
issues with the slash and backslash, as well as quotation marks,
mathematical or comparison symbols and the like. Stick with A-Z, 0-9,
and hyphens and underscores.

Our programming convention is that field names in forms match
corresponding field names in databases, as well as variable names.
Some of us still use three letter designations, such as strLastName or
frmLastname to designate either data type or where the field
originates, but we don't mandate it.

Jeff
 
Reply With Quote
 
Stuart Palmer
Guest
Posts: n/a
 
      10-30-2003
Good point, however I am dynamically building an email from the form and
these are the questions being processed into the output
email......'Do_you_have_any_suggestions/comments' it is easy to replace the
_ with spaces on the email but as the '/' and ',' are encoded, it causes me
a small problem. Like email -> strContent = fieldname & ": " &
request.form(fieldname)

Could you suggest another way I can implement form replies into a nice
layout that the recipient can understand?

Thx

Stu

"Chris Barber" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Not being argumentative but why would you ever want to have a form field
> name with a '/' in it - it's such a patently horrible thing to have to

deal
> with.
> My suggestion: change the field names.
>
> Chris.
>
> "Stuart Palmer" <(E-Mail Removed)> wrote in message
> news:bnqpfq$ug0$(E-Mail Removed)...
> Hi everyone,
> I have a form with '/' in some of the field names, when I pass through to
> the next page the field name comes back as though it's been htmlencoded,

so
> getting the value out of the field I need to convert this back to '/' with
> the replace (same problem if I have a ',' in the name)
>
> Is there an easy way to htmldecode or something what it converted to the
> encoded versions? (I have written a short function to basically do all my
> replaces for me, but I am guessing this isn't the ideal solution)
>
> Many thanks
>
> Stu
>
>
>
>



 
Reply With Quote
 
Jeff Cochran
Guest
Posts: n/a
 
      10-30-2003
On Thu, 30 Oct 2003 14:48:23 -0000, "Stuart Palmer"
<(E-Mail Removed)> wrote:

>Good point, however I am dynamically building an email from the form and
>these are the questions being processed into the output
>email......'Do_you_have_any_suggestions/comments' it is easy to replace the
>_ with spaces on the email but as the '/' and ',' are encoded, it causes me
>a small problem. Like email -> strContent = fieldname & ": " &
>request.form(fieldname)


That's not the field name, that's the input from the user. You said
your field names had a slash, not the input string. Field names
should never have a slash or quote in them. For the string input by
the user, you escape them if they will be a problem. You can also
Server.HTMLEncode them.

Example:

Form:

<form action='emailresults.asp'>
<P>Do you have any comments/suggestions?<input type='text'
name='comments' id='comments' value='None'></P>
<input type="submit" name="submit" id="submit" value="Submit">
</form>

emailresults.asp:

<%
strComment = Request.Form("comments")
Response.Write strComment
%>

This shouldn't be an issue if a slash is entered.

Jeff

>Could you suggest another way I can implement form replies into a nice
>layout that the recipient can understand?
>"Chris Barber" <(E-Mail Removed)> wrote in message
>news:(E-Mail Removed)...
>> Not being argumentative but why would you ever want to have a form field
>> name with a '/' in it - it's such a patently horrible thing to have to

>deal
>> with.
>> My suggestion: change the field names.
>>
>> Chris.
>>
>> "Stuart Palmer" <(E-Mail Removed)> wrote in message
>> news:bnqpfq$ug0$(E-Mail Removed)...
>> Hi everyone,
>> I have a form with '/' in some of the field names, when I pass through to
>> the next page the field name comes back as though it's been htmlencoded,

>so
>> getting the value out of the field I need to convert this back to '/' with
>> the replace (same problem if I have a ',' in the name)
>>
>> Is there an easy way to htmldecode or something what it converted to the
>> encoded versions? (I have written a short function to basically do all my
>> replaces for me, but I am guessing this isn't the ideal solution)
>>
>> Many thanks
>>
>> Stu
>>
>>
>>
>>

>


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
javascript validation for a not required field, field is onlyrequired if another field has a value jr Javascript 3 07-08-2010 10:33 AM
1.Enter space bar for field names and save the field.The field shoud not get saved and an alert should be there as"Space bars are not allowed" Sound Javascript 2 09-28-2006 02:43 PM
Read form "name" attribute when it contains form field with name "name" Pavils Jurjans Javascript 3 03-18-2005 01:39 PM
Difference between putting code in constructor and putting code in static{} Saurabh Java 6 05-30-2004 02:44 PM
Request.Form("Field Name") Versus Request.QueryString("Field Name") John Davis ASP General 2 08-18-2003 05:00 AM



Advertisments