输入形式-输入可以作为变量访问吗? [英] Input form - can inputs be accessed as variables?

查看:108
本文介绍了输入形式-输入可以作为变量访问吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

编辑以概述我的目标:

当用户点击提交"按钮时,我希望他们输入的金额和隐藏字段进入贝宝"添加到购物车.我希望单击相同的按钮即可发送他们输入到textarea中的信息,然后通过电子邮件发送到我们的电子邮件中.他们捐献了一定数量的款项,用于以自己的名义发送慰问卡/生日卡.页面上还有其他贝宝选项也添加到购物车中.

When user hits the submit button, I want the amount they entered and hidden fields to go to Paypal add to cart. I want that same click to send info they typed into textarea to be emailed to our email. They are donating an amount of their choice for use to send a sympathy/birthday card in their name. There are other paypal options on the page that get added to cart too.

如果可能的话,我想跳过js,这样他们就不必将其激活(网站上其他任何地方都不需要).

I'd like to skip js if possible so they don't have to have it activated (it's not needed anywhere else on the site.)

我可以发送到php,但是发现即使将其设置为target ="_ self",它也会打开一个新的浏览器选项卡,从而破坏了流程.

I can send to php but found that opens a new browser tab even when set to target="_self" so it ruins the flow.

如果我可以从输入表单中执行两个操作,并且让php不显示单独的页面...那就可以了.我一直在搜索,但都没有找到解决方案.大多数两个动作"是供两个不同的按钮选择的.

If I could do two actions from an input form, and have the php not display a separate page... that would do the trick. I've been searching but haven't found solutions for either. Most "two actions" are for two different buttons to choose from.

感谢您的阅读和帮助!

================= 原始问题:

================= Original question:

在包含输入表单的同一php/html文件中,是否可以访问在输入表单中从用户那里获取的变量?怎么样?

In the same php/html file that contains the input form -- can the variables that were gotten from the user in the input form -- be accessed? How?

所以

<input type="text" name="amount">

我可以再取款吗?在提交字段之前,可以在相同的输入表单中访问它.或在提交之后,之后但在同一文件中访问它.由于输入表单的动作是将其发送到Paypal,所以我不想将其发送到我自己的文件中并在那里进行处理.

Can I then access the amount? Either access it inside the same input form, before the submit field. Or access it after the submit, outside after, but in the same file. Since the input form's action is sending it to paypal, I don't want to send it to a file of my own and process it there.

我无法弄清楚获取可变数量的语法.

I can't figure out the syntax for grabbing the variable amount.

我已经搜索了好几天,但似乎找不到能给我任何东西的搜索,除非将它传递给另一个PHP文件该怎么做.或告诉我如何将其设置为变量.我是一名程序员,但对HTML还不陌生,所以我可能会错过明显的东西.

I've been searching for days, but can't seem to find a search that gives me anything except what to do if it's passed to another PHP file. Or tells me how to set this to variables. I'm a programmer but new enough to html, that I may be missing the obvious.

谢谢!

推荐答案

您将需要使用"id"和一些JavaScript.例如:

You'll need to use "id" and a little JavaScript. For example:

<input type="text" name="amount" id="amount">
<button onclick="alert('amount is: ' + document.getElementById('amount').value)">Show</button>

这篇关于输入形式-输入可以作为变量访问吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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