开发者

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. That part's easy, but the thing is I want the submit butt开发者_JAVA百科on to be a Flash object. Somehow I need the Flash button to submit the form, but I think I can figure that out. The tricky part is that I need it to set another PHP variable before submitting the form. The variable will be determined by a bunch of stuff, but I can code that in actionscript later. I just need to figure out how to pass the variable back to the webpage. A $_POST variable would probably be fine.

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? Can anyone help with making it submit the form as well while still catching a variable?


Look at ExternalInterface for calling JavaScript from ActionScript and vice versa.


Lars is right about it. It may look like this

ExternalInterface.call('passmyvariables','value1','value2');

Your javasscript would be something like this

function passmyvariables(var1,var2){

//process myvar

form.submit();

}

you can have multiple variables.


  1. An accessibility tip: avoid Flash when possible; it causes usability issues.
  2. If you want to add a POST variable before submitting:
    1. I don't think that Flash is allowed to access the DOM so this is JavaScript:
    2. Create an input element appended as a child of the form
    3. Set its type to hidden
    4. Set its value to whatever you want to send.

That's only part of the equation; I don't know how to get Flash to trigger a script in the page.

EDIT

These functions can help get data from Flash objects.

flashObject.GetVariable(variableName)

flashObject.SetVariable(variableName, value)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜