为多个文本字段指定同名的影响 [英] Impact of giving same name to multiple text fields

查看:71
本文介绍了为多个文本字段指定同名的影响的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好团队,


您能否告诉我一个解释 - 为HTML / ASP中的不同文本字段赋予相同的名称会产生什么影响。我使用JavaScript进行客户端验证和其他一些功能,用于数据库连接的VB脚本和DB的插入/更新操作。


感谢您的帮助。


问候,

Chandhseke

Hi Team,

Could you please educate me with an explanation - What is the impact of giving same name for different text fields in HTML/ASP. I use JavaScript for Client side validation and few other functionalities, VB script for DB connection and Insert/Update operation to DB.

Thanks for your help in advance.

Regards,
Chandhseke

推荐答案

说你的表格如下:
展开 | 选择 | Wrap | 行号


嗨Jared,

感谢您的回复。您的示例是正确的,但如果我有一个场景,我们已经提交了一个表单,并且使用Insert查询将所有表单值插入到数据库中。现在我有一个DB值<%= text1%>的表单。

Hi Jared,
Thanks for your response. Your example is correct but what if i have a scenario where we had submited a form and all form values is inserted to database using Insert query. Now i have a form with DB values <%=text1%>.

展开 | 选择 | Wrap | 行号


你是你的问题不太清楚,所以我很难理解你想要什么。


首先,为什么你有很多同名的字段?我的第一印象是这是不好的做法,但我承认有时候它会有意义。


其次,如果你的一个输入被禁用(如你的代码中那样)提交表单时不会发送值。


第三,当您使用相同的名称在多个输入中发送多个值时,它们不会作为不同的值发送到服务器,它们作为单个逗号分隔的字符串发送到服务器。因此,如果您有三个文本输入,名称为text1,和价值mamba它们不会发送给服务器作为
You are not very clear on your question, so I am having a hard time understanding exactly what you want.

First, Why do you have a lot of fields with the same name? My first impression is that this is bad practice, but I admit there are times when it would make sense.

Second, if one of your inputs is disabled (as in your code) that value will not be sent when the form is submitted.

Third, when you send multiple values in multiple inputs with the same name, they are not sent to the server as different values, they are sent to the server as a single comma-separated string. So if you have three text inputs with name "text1" and value "mamba" they ARE NOT SENT TO THE SERVER AS
展开 | 选择 < span class =codeDivider> | Wrap | 行号


这篇关于为多个文本字段指定同名的影响的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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