通过表单循环得到字段名和字段值的问题(传统的ASP) [英] Looping through a form to get field names and filed values issue (classic ASP)

查看:134
本文介绍了通过表单循环得到字段名和字段值的问题(传统的ASP)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一种形式提交,我想捕捉的形式字段名称和值,我想他们不会在浏览器中显示,即使经过(回复于让他们看到在浏览器中)。我怎么能这样做吗?我用这code:

 对于每个项目的Request.Form
    字段名=项目
    fieldValue方法=的Request.Form(项目)    回复于(与& fieldName的&放大器;=的Request.Form(与& fieldName的&放大器;,))
    下一个


解决方案

您code是基本上是正确的,所以才删除的Response.Write 和做其他事与字段名 fieldValue方法变量,你填充。你和操纵数据(无论其插入到数据库或发送电子邮件)完成后,可以将用户重定向到一个成功/谢谢你的页面。

要测试您收到正确的输入,你可以改变你的的Response.Write

 的Response.Write字段名和放大器; =&放大器; fieldValue方法和放大器; < BR>中

结果

更新

下面是你如何可以使用Dictionary对象把你的字段名和字段值加在一起:

 昏暗的项目,字段名,fieldValue方法
暗淡的A,B,C,D集合D =的Server.CreateObject(的Scripting.Dictionary)对于每个项目的Request.Form
    字段名=项目
    fieldValue方法=的Request.Form(项目)    d.Add字段名,fieldValue方法
下一个在code的休息是通过字典去
一个运行起来也字段名
B = d.Items'字段值对于c = 0到d.Count - 1
    RESPONSE.WRITE一(C)及=&放大器;公元前)
    的Response.Write< BR>中
下一个

on submit of a form, I would like to capture the field names and values of the forms and I want them passed without even showing in the browser (Response.Write makes them visible in the browser). How I can do this please? I am using this code:

    For Each Item In Request.Form
    fieldName = Item
    fieldValue = Request.Form(Item)

    Response.Write(""& fieldName &" = Request.Form("""& fieldName &""")")       
    Next 

解决方案

Your code is essentially correct, so just remove the Response.Write and do something else with the fieldName and fieldValue variables you're populating. After you're done with manipulating the data (either inserting it into a database or sending an e-mail), you can redirect the user to a success / thank you page.

To test that you're receiving the correct input, you can change your Response.Write to

Response.Write fieldName & " = " & fieldValue & "<br>"


Update

Here's how you could use a Dictionary Object to put your field names and field values together:

Dim Item, fieldName, fieldValue
Dim a, b, c, d

Set d = Server.CreateObject("Scripting.Dictionary")

For Each Item In Request.Form
    fieldName = Item
    fieldValue = Request.Form(Item)

    d.Add fieldName, fieldValue
Next

' Rest of the code is for going through the Dictionary
a = d.Keys  ' Field names  '
b = d.Items ' Field values '

For c = 0 To d.Count - 1
    Response.Write a(c) & " = " & b(c)
    Response.Write "<br>"
Next

这篇关于通过表单循环得到字段名和字段值的问题(传统的ASP)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆