0
下面是它處理正常的提交按鈕的功能:我要上傳按鈕不會觸發功能
<script type="text/javascript">
$(function() {
myClickHandler=function(e){
if (!validation())
return false;
if (!confirm("Are you sure you want to Proceed?" + "\n"))
return false;
return true;
};
$('#QandA').submit(myClickHandler);
});
</script>
下面我顯示了imageuploadform,audiouploadform和視頻uploadform如何追加到一個表,該表中所述#QandA
形式:
的jquery:
function insertQuestion(form) {
var $image = $("<td class='image'></td>");
var $fileImage = $("<form action='imageupload.php' method='post'
enctype='multipart/form-data' target='upload_target_image'
onsubmit='return imageClickHandler(this);'
class='imageuploadform' >" +
"Image File: <input name='fileImage' type='file'
class='fileImage' /></label><br/><br/><label class='imagelbl'>" +
"<input type='submit' name='submitImageBtn'
class='sbtnimage' value='Upload' /></label></form>");
$image.append($fileImage);
$tr.append($image);
var $video = $("<td class='video'></td>");
var $fileVideo = $("<form action='videoupload.php' method='post'
enctype='multipart/form-data' target='upload_target_video'
onsubmit='return videoClickHandler(this);'
class='videouploadform' >" +
"Video File: <input name='fileVideo' type='file'
class='fileVideo' /></label><br/><br/><label class='videolbl'>" +
"<input type='submit' name='submitVideoBtn'
class='sbtnvideo' value='Upload' /></label></form>");
$video.append($fileVideo);
$tr.append($video);
var $audio = $("<td class='audio'></td>");
var $fileAudio = $("<form action='audioupload.php' method='post'
enctype='multipart/form-data' target='upload_target_audio'
onsubmit='return audioClickHandler(this);'
class='audiouploadform' >" +
"Audio File: <input name='fileAudio' type='file'
class='fileAudio' /></label><br/><br/><label class='audiolbl'>" +
"<input type='submit' name='submitAudioBtn'
class='sbtnaudio' value='Upload' /></label></form>");
$audio.append($fileAudio);
$tr.append($audio);
}
HTML(#QandA形式):
<form id="QandA" action="<?php echo htmlentities($action); ?>" method="post">
//image, video and audio upload form is appended into table below:
<table id="qandatbl" align="center" cellpadding="0" cellspacing="0" border="0">
<thead>
<tr>
<th class="image">Image</th>
<th class="video">Video</th>
<th class="audio">Audio</th>
</tr>
</thead>
</table>
<div id="qandatbl_onthefly_container">
<table id="qandatbl_onthefly" align="center" cellpadding="0" cellspacing="0" border="0">
<tbody>
</tbody>
</table>
<p><input id="submitBtn" name="submitDetails" type="submit" value="Submit Details" /></p>
</form>
現在發生的事情是,圖像,視頻和音頻上傳提交按鈕觸發myClickHandler()函數,它不應該,只有#submitBtn
應該觸發此功能。如何停止觸發myClickHandler()
功能的圖像,音頻和視頻上傳按鈕。
UPDATE:
<script type="text/javascript">
$(function() {
$('#submitBtn').click(myClickHandler(e))
});
function myClickHandler(e){
if (!validation())
return false;
if (!confirm("Are you sure you want to Proceed?" + "\n"))
return false;
return true;
};
</script>
這是問題壽,我試圖做'$( '#submitBtn')提交(myClickHandler);'但沒有奏效 – Manixman
嘗試$('# submitBtn')。點擊(myClickHandler(e)) –
我試着通過替換' $('#QandA')。submit(myClickHandler);'上傳按鈕不會觸發這種很好的功能,但如果我點擊「提交詳細信息」按鈕,它不會觸發該功能。 – Manixman