在单页上不止一种形式(More than one form on a single page)

2019-07-29 19:10发布

我的个人资料编辑页面上的我的图像上传表单无法正常工作。 他们独立工作,这两种形式必须是独立的。 图片上传脚本上传的档案编辑表单提交前的图像。

我测试的图片上传一个单独的页面上它是页面上的唯一和它的工作。 所以我假设它是被搞乱它的其他形式。 这两种形式的作用在不同的脚本和这两种方法的帖子。

这里是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>

Answer 1:

有没有在你的cropimage形式提交按钮,这可能是铅。 如果我没有理解好,你要当有在photoimg领域的改变,没有提交按钮将其提交。

尝试按提交表单中输入不提交按钮 (显示在屏幕外的提交按钮,如果你不想显示它)。

BTW,jQuery的现场已被弃用。 http://api.jquery.com/live/



文章来源: More than one form on a single page