单个页面上有多个表单

时间:2012-06-07 16:56:14

标签: php html forms upload

我的个人资料编辑页面上的我的图片上传表单无效。这两种形式必须分开,因为它们独立工作。图像上传脚本在提交配置文件编辑表单之前上载图像。

我在一个单独的页面上测试了图片上传,这是页面上唯一的内容并且它有效。所以我认为这是另一种形式搞砸了。这两种形式表现在不同的脚本上,两种方法都是帖子。

这是jscript

<script type="text/javascript" src="imageupload/scripts/jquery.min.js"></script>
<script type="text/javascript" src="imageupload/scripts/jquery.form.js"></script>
<script type="text/javascript" >
  $(document).ready(function() { 
    $('#photoimg').live('change', function() { 
        $("#preview").html('');
        $("#preview").html('<img src="imageupload/loader.gif" alt="Uploading...."//>');
        $("#cropimage").ajaxForm({ target: '#preview' }).submit();
    });
  }); 
</script>

这是表格;

<form id="cropimage" method="post" enctype="multipart/form-data" action="../imageupload/ajaximage.php">
  <input type="file" name="photoimg" id="photoimg" class="filebutton"/><br>
</form>

这是另一种形式。它很长;

    echo '<form action="phpscripts/artistupdate.php" method="post" id="profileedit"><input type="text" name="artistname" value="'. $row['artistname'].'" class="name"     maxlength="80"><span id="editlink"><t1>Your profile link will be: <br><a     href="http://newbornsounds.co.uk/artists/artist.php?artist='.$row['artistname'].'">    <b>http://newbornsounds.co.uk/artists/artist.php?artist=<FONT style="BACKGROUND-COLOR: yellow">'.$row['artistname'].'</font></b></a></span><br><div id="urlwarn"><t1>Please note that if you change your url all the links you have placed outside of NBS will be affected.</t1></div>';
  }
}
?>
<hr>
<?php 
  $username = $_SESSION['username'];
  $pass = $_SESSION['password']; 
  include ("../database.php");
  $result = mysql_query("SELECT * FROM members WHERE username='$username' AND     password='$pass' AND artist='Y'");

  while($row = mysql_fetch_array($result)){
    echo '<div id="artistsbio"><textarea name="bio" rows="10" cols="80" name="bio" value="'.     $row['bio']. '" class="bio">'. $row['bio']. '</textarea><br><div id="probwarn"><t1>Everything is still in the beta stage so there are bound to be a few problems. If you spot one please <a     href="mailto:artists@newbornsounds.co.uk"><b>tell us about it.</b></a></t1></div>';
  }
?>
<br><br>
<input type="submit" name="submit" value="Done" class="button"></form>

1 个答案:

答案 0 :(得分:0)

您的cropimage表单中没有提交按钮,可能是pb。 如果我理解得很好,您希望在photoimg字段发生更改时提交,而不提交按钮。

试试Submitting a form by pressing enter without a submit button (如果您不想显示,请在屏幕外显示提交按钮。)

BTW,jquery live已被弃用。 http://api.jquery.com/live/