一页上有多个表格 [英] More than one form on a single page

查看:71
本文介绍了一页上有多个表格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的个人资料编辑页面上的图像上传表格不起作用.两种形式必须分开,因为它们是独立工作的.图像上传脚本会在提交配置文件编辑表单之前上传图像.

My image upload form on my profile edit page isn't working. The two forms must be separate as they work independently. The image upload script uploads the image before the profile edit form is submitted.

我在单独的页面上测试了图片上传,这是页面上唯一的东西,并且可以正常工作.因此,我认为这是另一种形式.两种形式都作用于不同的脚本,并且这两种方法都是帖子.

I tested the image upload on a separate page where it was the only thing on the page and it worked. So I am assuming it is the other form that is messing it up. The two forms are acting on different scripts and both methods are posts.

这是脚本

<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>

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

Here is the other form. Its a long one;

    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>

推荐答案

cropimage表单中没有提交按钮,可能是pb. 据我了解,您希望Photoimg字段中的内容发生更改时提交,而无需提交按钮.

There is no submit button in your cropimage form, which might be the pb. If I understand well, you want it to be submitted when there is a change in the photoimg field, without submit button.

尝试通过按Enter提交表单没有提交按钮 (如果您不想显示提交按钮,则在屏幕外部显示它.)

Try Submitting a form by pressing enter without a submit button (displaying a submit button outside the screen if you don't want to display it).

顺便说一句,jQuery live已被弃用. http://api.jquery.com/live/

BTW, jquery live is deprecated. http://api.jquery.com/live/

这篇关于一页上有多个表格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆