找出按下了哪个表格按钮 [英] Figuring out which form button was pressed

查看:59
本文介绍了找出按下了哪个表格按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的vb.net页面上,我有4组输入+表格按钮。


例如:


搜索:[___________ ](GO)

邮编:[____________](GO)

县:[选择一个县| \ /](GO)

县:[选择建筑物| \ /](转发)


问题是,如果我进入页面,输入邮政编码,然后按回车。


会发生SEARCH按钮被触发...而不是ZIP按钮。


有没有办法自动将焦点移动到正确的提交按钮

点击返回?


-Darrel

On my vb.net page, I have 4 sets of inputs + form buttons.

example:

Search: [___________] (GO)
Zip: [____________] (GO)
County: [select a county | \/ ] (GO)
County: [select a building | \/ ] (GO)

The problem is if I go to the page, type in a zip code, and hit enter.

What happens is that the SEARCH button is triggered...not the ZIP button.

Is there any way to automatically move focus to the correct submit button
upon hitting return?

-Darrel

推荐答案

darrel写道:
在我的vb.net页面上,我有4组输入+表格按钮。

例如:

搜索:[___________](GO)县:[选择一个县| \ /](GO)
县:[选择建筑物| \ /](GO)

问题是,如果我进入页面,输入邮政编码,然后按回车。

SEARCH按钮会发生什么触发...而不是ZIP按钮。

有什么方法可以在返回时自动将焦点移动到正确的提交按钮
On my vb.net page, I have 4 sets of inputs + form buttons.

example:

Search: [___________] (GO)
Zip: [____________] (GO)
County: [select a county | \/ ] (GO)
County: [select a building | \/ ] (GO)

The problem is if I go to the page, type in a zip code, and hit enter.

What happens is that the SEARCH button is triggered...not the ZIP button.

Is there any way to automatically move focus to the correct submit button
upon hitting return?



我敢肯定这可以通过使用JavaScript来实现,但是

听起来像是一个糟糕的设计,最终会让很多用户感到困惑

当他们点击输入按钮时也不知道会发生什么。为什么

很多GO按钮?


我会认真地建议重新考虑你的设计,除非你有很好的理由这样做。


-

Sean



I''m sure this could be accomplished some how using JavaScript, but that
sounds like a bad design and will ultimately confuse many users who will
also not know what to expect when they hit the enter button. Why have
many "GO" buttons?

I''d seriously recommend rethinking your design unless you have a very
good reason to do that.

--
Sean


你可以在每个表格上放置一个隐藏字段,名称相同,例如hfField

但是给它们所有不同的值,例如value =" Search,value =" Zip。


on hte服务器只是说:


如果请求(" hffield")=" Zip"然后

做邮政编码

elseIf request(" hffield")=" Search"然后

做搜索代码等


它有点令人费解但它确实有效。


希望这有助于。

you could place a hidden field on each form with the same name e.g "hfField"
but give them all different values e.g "value ="Search", value="Zip".

The on hte server just say something like :

If request("hffield") = "Zip" then
do the zip code
elseIf request("hffield") = "Search" then
do the search code e.t.c.

Its a bit convoluted but it does work.

Hope this helps.


VB.Net可以有一个默认按钮...


将此添加到你的page_load。


Page.RegisterHiddenField(" __ EVENTTARGET"," btnSearch")

如果您希望触发相应的按钮在

他们在哪个领域,尝试javascript ...但我也会重新考虑你的

设计。

Fao,Sean写道:
VB.Net can have one default button...

Add this to your page_load.

Page.RegisterHiddenField("__EVENTTARGET", "btnSearch")

If you''re looking to have the appropriate button triggered based on
what field they''re in, try javascript... but I would also rethink your
design.
Fao, Sean wrote:
darrel写道:
在我的vb.net页面上,我有4组输入+表格按钮。

示例:

搜索:[___________](GO)
邮编:[____________](GO)
县:[选择一个县| \ /](GO)
县:[选择建筑物| \ /](GO)

问题是,如果我进入页面,输入邮政编码,然后按回车。

SEARCH按钮会发生什么触发...而不是ZIP按钮。

有什么方法可以在返回时自动将焦点移动到正确的提交按钮
On my vb.net page, I have 4 sets of inputs + form buttons.

example:

Search: [___________] (GO)
Zip: [____________] (GO)
County: [select a county | \/ ] (GO)
County: [select a building | \/ ] (GO)

The problem is if I go to the page, type in a zip code, and hit enter.

What happens is that the SEARCH button is triggered...not the ZIP button.

Is there any way to automatically move focus to the correct submit button
upon hitting return?


我相信这可以通过使用JavaScript来实现,但这听起来像是一个糟糕的设计,最终会让许多用户感到困惑,他们也不知道当他们点击输入按钮时会发生什么。为什么
很多GO按钮?

我会认真地建议重新考虑你的设计,除非你有充分的理由这样做。

-
Sean



I''m sure this could be accomplished some how using JavaScript, but that
sounds like a bad design and will ultimately confuse many users who will
also not know what to expect when they hit the enter button. Why have
many "GO" buttons?

I''d seriously recommend rethinking your design unless you have a very
good reason to do that.

--
Sean






这篇关于找出按下了哪个表格按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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