如何使用EMPTY操作以html格式发布数据?

时间:2013-10-18 19:05:42

标签: post action

如何在不设置操作的情况下从html发布帖子中的数据?

以下是代码:

<form name="form_upload" id="form_upload" method="post" enctype="multipart/form-data"  action="[var.path_to_upload_script]" style="margin: 0px; padding: 0px;">

那么我有什么方法可以通过空白操作将数据发送到[var.path_to_upload_script]?我的意思是action=""

整个行看起来像那样:

<form name="form_upload" id="form_upload" method="post" enctype="multipart/form-data"  action="" style="margin: 0px; padding: 0px;">

我知道必须在上面添加一些内容,但我不知道是什么,因此表单会将数据发送到[var.path_to_upload_script],操作为空白。

那有什么办法吗?我已经测试了onSubmit="",但它无效。

1 个答案:

答案 0 :(得分:0)

您需要执行以下操作

<form name="form_upload" id="form_upload" method="post" enctype="multipart/form-data"  action="" style="margin: 0px; padding: 0px;" onsubmit="return myfx(params);">
   Put you fields here
</form>

你的功能应该像

function myfx(params)
{
  if(ok)
  {
     //Print via PHP
     document.forms[].action = "<?php $path_to_upload_script; ?>";
     //Using a js variable, in this case the variable must be set somewhere
     document.forms[].action = path_to_upload_script;
     return true;
  }
  else
  {
     do anycoding 
     return false;
  }
}

它可以是php或javascript变量,但必须在动作行中设置。

不验证表格

    function myfx(params)
{
     //Print via PHP
     document.forms[].action = "<?php $path_to_upload_script; ?>";
     //Or
     //Using a js variable, in this case the variable must be set somewhere
     document.forms[].action = path_to_upload_script;
     return true;

}