简体   繁体   English

HTML表单-> Flash提交按钮->在Flash按钮中设置PHP变量->提交表单

[英]HTML form -> Flash submit button -> Set a PHP variable in flash button -> Submit form

Okay, I'm sorry that this is pretty complicated, but it shouldn't be that hard to solve... 好吧,很抱歉这很复杂,但是解决起来应该不难...

Here's what I want to do. 这就是我想要做的。 I have an HTML form that I want to upload to MySQL with PHP. 我有一个HTML表单,我想使用PHP上传到MySQL。 That part's easy, but the thing is I want the submit button to be a Flash object. 那部分很简单,但是我想让Submit按钮成为Flash对象。 Somehow I need the Flash button to submit the form, but I think I can figure that out. 我以某种方式需要Flash按钮来提交表单,但是我想我可以弄清楚这一点。 The tricky part is that I need it to set another PHP variable before submitting the form. 棘手的是,我需要它在提交表单之前设置另一个PHP变量。 The variable will be determined by a bunch of stuff, but I can code that in actionscript later. 该变量将由一堆东西决定,但是稍后我可以在actionscript中对其进行编码。 I just need to figure out how to pass the variable back to the webpage. 我只需要弄清楚如何将变量传递回网页。 A $_POST variable would probably be fine. $ _POST变量可能没问题。

Thanks!! 谢谢!! Let me know if I need to clarify more... 让我知道是否需要进一步说明...

edit: What if the flash object returned some javascript and set a variable that way? 编辑:如果Flash对象返回了一些JavaScript并以这种方式设置了变量,该怎么办? Can anyone help with making it submit the form as well while still catching a variable? 任何人都可以帮助它在仍然捕获变量的同时提交表单吗?

查看ExternalInterface,以从ActionScript调用JavaScript,反之亦然。

Lars is right about it. 拉斯对此是正确的。 It may look like this 它可能看起来像这样

ExternalInterface.call('passmyvariables','value1','value2'); ExternalInterface.call( 'passmyvariables', 'VALUE1', '值2');

Your javasscript would be something like this 您的Javasscript将是这样的

function passmyvariables(var1,var2){ 函数passmyvariables(var1,var2){

//process myvar //处理myvar

form.submit(); form.submit();

} }

you can have multiple variables. 您可以有多个变量。

  1. An accessibility tip: avoid Flash when possible; 无障碍提示:尽可能避免使用Flash; it causes usability issues. 它会导致可用性问题。
  2. If you want to add a POST variable before submitting: 如果要在提交之前添加POST变量,请执行以下操作:
    1. I don't think that Flash is allowed to access the DOM so this is JavaScript: 我认为不允许Flash访问DOM,所以这是JavaScript:
    2. Create an input element appended as a child of the form 创建一个input元素,该input元素附加为form的子元素
    3. Set its type to hidden 将其type设置为hidden
    4. Set its value to whatever you want to send. 将其value设置为您要发送的任何value

That's only part of the equation; 那只是方程式的一部分 I don't know how to get Flash to trigger a script in the page. 我不知道如何让Flash触发页面中的脚本。

EDIT 编辑

These functions can help get data from Flash objects. 这些功能可以帮助从Flash对象获取数据。

flashObject.GetVariable(variableName)

flashObject.SetVariable(variableName, value)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM