0

I am working with a legacy form builder system that can have non-alphanumeric fieldnames so for example

< input type=text name="5-Teléfono">

and in asp, simply doing the following will not output the posted value

response.write (request('5-Teléfono'))

I understand this isn't the best design decision (should probably name the fields text_123 ... etc), however updating the whole system to use this structure would take time.

Is there a way in asp for me to read form field names with non-alphanumerics ?

kkuni
  • 67
  • 1
  • 1
  • 8
  • What browser? Have you set [`Response.Charset`](http://msdn.microsoft.com/en-us/library/ms525304%28v=vs.90%29.aspx) and [`@CODEPAGE`](http://msdn.microsoft.com/en-us/library/ms524967%28v=vs.90%29.aspx)? See [this SO answer](http://stackoverflow.com/a/352393/249624) for more information. – Cheran Shunmugavel Mar 05 '13 at 06:14

2 Answers2

0

Try

response.write (request("5-Teléfono"))

(ie with double quotes around 5-Teléfono)

Single quotes in vbscript are used to comment out what comes afterwards

John
  • 4,658
  • 2
  • 14
  • 23
  • Thanks John, that was a mistake when I was typing in my question. Through some testing, it looks like the field is converted to "5-Teléfono" instead of 5-Teléfono .. .which seems to be causing the error ... any idea how I can get this resovled ? – kkuni Mar 04 '13 at 22:03
  • Open all the relevant files in Notepad. Select Save As from the File menu and if the encoding dropdown is set to ANSI then change it to UTF-8. It might also be a good idea to add a meta charset=utf-8 tag in your form page. I've tested this and it works – John Mar 04 '13 at 22:57
0

Don't use such names, it's like using non English variable names - same impact.

If you can't change the name, you can still iterate the posted values and look for the proper one:

For Each key In Request.Form
    If (InStr(key, "fono") > 0) And (InStr(key, "5-Tel") > 0) Then
        Response.Write("Found, value is: " & Request.Form(key))
    End If
Next
Shadow The GPT Wizard
  • 66,030
  • 26
  • 140
  • 208