亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定

點擊添加附件沒反應

老師,我點擊添加附件之后,沒有任何反應,瀏覽器底部出現一條javascript:void(0),并不出現文件選擇框,求解

<?php
require_once?'../include.php';
checkLogined();
$rows?=?getAllCate();
//print_r($rows);
if(!$rows){
	alertMes("沒有相應分類,請先添加","addCate.php");
}
?>

<!doctype?html>
<html>
<head>
<meta?charset="utf-8">
<title>-.-</title>
<link?href="./styles/global.css"??rel="stylesheet"??type="text/css"?media="all"?/>
<script?type="text/javascript"?charset="utf-8"?src="../plugins/kindeditor/kindeditor.js"></script>
<script?type="text/javascript"?charset="utf-8"?src="../plugins/kindeditor/lang/zh_CN.js"></script>
<script?type="text/javascript"?src="./scripts/jquery-1.6.4.js"></script>
<script>
????????KindEditor.ready(function(K)?{
????????????????window.editor?=?K.create('#editor_id');
????????});
????????$(document).ready(function(){
????????	$("#selectFileBtn").click(function(){
????????		$fileField?=?$('<input?type="file"?name="thumbs[]"/>');
????????		$fileField.hide();
????????		$("#attachList").append($fileField);
????????		$fileField.trigger("click");
????????		$fileField.change(function(){
????????		$path?=?$(this).val();
????????		$filename?=?$path.substring($path.lastIndexOf("\\")+1);
????????		$attachItem?=?$('<div?class="attachItem"><div?class="left">a.gif</div><div?class="right"><a?href="#"?title="刪除附件">刪除</a></div></div>');
????????		$attachItem.find(".left").html($filename);
????????		$("#attachList").append($attachItem);		
????????		});
????????	});
????????	$("#attachList>.attachItem").find('a').live('click',function(obj,i){
????????		$(this).parents('.attachItem').prev('input').remove();
????????		$(this).parents('.attachItem').remove();
????????	});
????????});
</script>
</head>
<body>
<h3>添加商品</h3>
<form?action="doAdminAction.php?act=addPro"?method="post"?enctype="multipart/form-data">
<table?width="70%"??border="1"?cellpadding="5"?cellspacing="0"?bgcolor="#cccccc">
	<tr>
		<td?align="right">商品名稱</td>
		<td><input?type="text"?name="pName"??placeholder="請輸入商品名稱"/></td>
	</tr>
	<tr>
		<td?align="right">商品分類</td>
		<td>
		<select?name="cId">
			<?php?foreach($rows?as?$row):?>
				<option?value="<?php?echo?$row['id'];?>"><?php?echo?$row['cName'];?></option>
			<?php?endforeach;?>
		</select>
		</td>
	</tr>
	<tr>
		<td?align="right">商品貨號</td>
		<td><input?type="text"?name="pSn"??placeholder="請輸入商品貨號"/></td>
	</tr>
	<tr>
		<td?align="right">商品數量</td>
		<td><input?type="text"?name="pNum"??placeholder="請輸入商品數量"/></td>
	</tr>
	<tr>
		<td?align="right">商品市場價</td>
		<td><input?type="text"?name="mPrice"??placeholder="請輸入商品市場價"/></td>
	</tr>
	<tr>
		<td?align="right">商品慕課價</td>
		<td><input?type="text"?name="iPrice"??placeholder="請輸入商品慕課價"/></td>
	</tr>
	<tr>
		<td?align="right">商品描述</td>
		<td>
			<textarea?name="pDesc"?id="editor_id"?style="width:100%;height:150px;"></textarea>
		</td>
	</tr>
	<tr>
		<td?align="right">商品圖像</td>
		<td>
			<a?href="javascript:void(0)"?id="selectFileBtn">添加附件</a>
			<div?id="attachList"?class="clear"></div>
		</td>
	</tr>
	<tr>
		<td?colspan="2"><input?type="submit"??value="發布商品"/></td>
	</tr>
</table>
</form>
</body>
</html>


正在回答

6 回答

方法試了,不可以

0 回復 有任何疑惑可以回復我~

方案一:trigger("click")寫在change事件后

方案二:

$("#selectFileBtn").click(function(event) {

$fileFiled=$('<input type="file" name="thumbs[]"/>' );

$fileFiled.hide();

$("#attachList").append($fileFiled);

$fileFiled.trigger('click');

$fileFiled.change(function(event) {

//console.log("change");

$path=$(this).val();

$filename=$path.substring($path.lastIndexOf("\\")+1);

if($path!=""){

$attachItem=$('<div class="attachItem"><div class="left">a.gif</div><a href="javascript:void(0)" title="刪除附件">刪除</a></div>');

$attachItem.find(".left").html($filename);

$("#attachList").append($attachItem);

$a=$("#attachList>.attachItem").find("a");

//console.log("第二次算a數量為:"+$a.length);

$a.click(function(){

? ?//console.log("觸發了click事件");

? ?$(this).parents('.attachItem').prev('input').remove();

$(this).parents('.attachItem').remove();

})

}

});

//$fileFiled.trigger('change'); ?//egde 瀏覽器不寫這句不能顯示?!

$a=$("#attachList>.attachItem").find("a");

if($a.length==0){

//console.log("a數量為零,手動觸發change事件");

$fileFiled.trigger('change');

}

//event.stopPropagation();

});

即手動模擬觸發一下change

ps:我也不知道為什么,但是測試后發現好像egde瀏覽器在trigger("click")觸發后后續的代碼就不會執行,因此,選擇文件完成后,才會執行后續代碼,因此對于change事件而言,相當于沒有change

2 回復 有任何疑惑可以回復我~
#1

髢篭

666 ok 了
2017-03-05 回復 有任何疑惑可以回復我~

大神請問你是怎么解決的呢?能說下嗎?謝謝

1 回復 有任何疑惑可以回復我~

求解

????


0 回復 有任何疑惑可以回復我~

如何解決的?


0 回復 有任何疑惑可以回復我~

以解決?

1 回復 有任何疑惑可以回復我~
#1

天添1991

同學,請問是如何解決的?急
2015-12-25 回復 有任何疑惑可以回復我~

舉報

0/150
提交
取消
手把手教你實現電商網站后臺開發
  • 參與學習       117253    人
  • 解答問題       2101    個

手把手教你用PHP搭建電子商務平臺,由淺入深教你搭建電商系統

進入課程

點擊添加附件沒反應

我要回答 關注問題
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號