博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
vue 侦听器侦听对象属性_PHP表单帮助器–提交侦听器
阅读量:2513 次
发布时间:2019-05-11

本文共 2223 字,大约阅读时间需要 7 分钟。

vue 侦听器侦听对象属性

Unfortunately for me, web forms a big part of my day. It's not that web forms are difficult, it's that they're so damn time consuming. Validation, formatting, and processing are a must for web forms and the redundancy that goes into performing the task over and over is enough to drive a developer crazy.

对我来说不幸的是,网络是我一天中很重要的一部分。 并不是说网络表单很困难,而是因为它们是如此的耗时。 验证,格式化和处理是Web表单所必需的,一遍又一遍地执行任务所需要的冗余足以使开发人员发疯。

The trigger to the form validation and subsequent processing is form submission. How do you know when a form has been submitted? At the top of the PHP script, before any output, you code:

表单验证和后续处理的触发因素是表单提交。 您如何知道何时提交表单? 在PHP脚本的顶部,在进行任何输出之前,您需要编写以下代码:

if(isset($_POST['submit'])) {	//validation here	//conditional processing here}

What if there's also a "cancel" button? You'd code:

如果还有一个“取消”按钮怎么办? 您将代码:

if(isset($_POST['submit'])) {	//validation here	//conditional processing here}elseif(isset($_POST['cancel'])) {	//redirect somewhere<}

The above isn't good enough for me. I create too many forms to continue the isset() muck. Also, what about the "_x" browser quirk for when you have an image submit button (e.g. instead of PHP reading in "submit", it reads in "submit_x")? What about maintainability? I've created a function to handle all form submission situations that works great for my purposes.

以上对我来说还不够好。 我创建了太多表格,无法继续isset()废话。 另外,当您有图像提交按钮时,“ _ x”浏览器会有什么古怪之处(例如,不是在“ submit”中读取PHP,而是在“ submit_x”中读取)? 可维护性如何? 我创建了一个功能来处理所有表单提交情况,这些功能非常适合我的目的。

代码 (The Code)

function submit($trigger = 'submit') {	return (isset($_POST[$trigger]) || isset($_POST[$trigger.'_x']) || isset($_GET[$trigger]) || isset($_GET[$trigger.'_x']));}

用法 (The Usage)

if(submit()) {	//submit button pressed}elseif(submit('cancel')) {	//cancel button pressed}

说明 (The Explanation)

There's one optional argument to send to the function: $trigger. $trigger represents the name of the button you expect to be pressed -- default being "submit." If one of the buttons is pressed, the selected processing is run; if not, no processing is run.

有一个可选的参数发送给函数: $ trigger 。 $ trigger表示您希望按下的按钮的名称-默认为“提交”。 如果按下其中一个按钮,则运行所选的处理; 如果不是,则不运行任何处理。

Do you have a function you use? If so, please share.

您有使用的功能吗? 如果是这样,请分享。

翻译自:

vue 侦听器侦听对象属性

转载地址:http://tzpwd.baihongyu.com/

你可能感兴趣的文章
Navicat远程连接云主机数据库
查看>>
Nginx配置文件nginx.conf中文详解(总结)
查看>>
jxl写入excel实现数据导出功能
查看>>
linux文件目录类命令|--cp指令
查看>>
.net MVC 404错误解决方法
查看>>
linux系统目录结构
查看>>
git
查看>>
btn按钮之间事件相互调用
查看>>
Entity Framework 4.3.1 级联删除
查看>>
codevs 1163:访问艺术馆
查看>>
冲刺Noip2017模拟赛3 解题报告——五十岚芒果酱
查看>>
并查集
查看>>
sessionStorage
查看>>
代码示例_进程
查看>>
Java中关键词之this,super的使用
查看>>
学习进度
查看>>
“此人不存在”
查看>>
github.com加速节点
查看>>
解密zend-PHP凤凰源码程序
查看>>
python3 序列分片记录
查看>>